Real time perspective correction on faces

ABSTRACT

Apparatus and methods related to image processing are provided. A computing device can determine a first image area of an image, such as an image captured by a camera. The computing device can determine a warping mesh for the image with a first portion of the warping mesh associated with the first image area. The computing device can determine a cost function for the warping mesh by: determining first costs associated with the first portion of the warping mesh that include costs associated with face-related transformations of the first image area to correct geometric distortions. The computing device can determine an optimized mesh based on optimizing the cost function. The computing device can modify the first image area based on the optimized mesh.

CROSS-REFERENCE TO RELATED APPLICATIONS

This patent application claims priority to U.S. Provisional PatentApplication No. 62/880,903 filed on Jul. 31, 2019, entitled “Real TimePerspective Correction on Faces”, the contents of which are entirelyincorporated herein by reference for all purposes.

BACKGROUND

Many modern computing devices, including mobile phones, personalcomputers, and tablets, include image capture devices, such as stilland/or video cameras. The image capture devices can capture images, suchas images that include people, animals, landscapes, and/or objects.

Some image capture devices and/or computing devices can correct capturedimages. For example, some image capture devices can provide “red-eye”correction that removes artifacts such as red-appearing eyes of peopleand animals that may be present in images captured using bright lights,such as flash lighting. After a captured image has been corrected, thecorrected image can be saved, displayed, transmitted, printed to paper,and/or otherwise utilized.

SUMMARY

In one aspect, a computer-implemented method is provided. Image datarepresenting an image is received. A first image area corresponding to afirst region of interest in the image is determined. A warping mesh forthe image is determined. A first portion of the warping mesh associatedwith the first image area is determined. A cost function for the warpingmesh is determined by: determining first costs associated with the firstportion of the warping mesh, where the first costs include costsassociated with one or more face-related transformations of at least thefirst image area to correct one or more geometric distortions of thefirst region of interest as represented in the image. An optimized meshbased on an optimization of the cost function for the warping mesh isdetermined. The first image area of the image based on the optimizedmesh is modified.

In another aspect, a computing device is provided. The computing deviceincludes: one or more processors; and one or more computer readablemedia having computer-readable instructions stored thereon that, whenexecuted by the one or more processors, cause the computing device tocarry out functions. The functions include: receiving image datarepresenting an image; determining a first image area corresponding to afirst region of interest in the image; determining a warping mesh forthe image; determining a first portion of the warping mesh associatedwith the first image area; determining a cost function for the warpingmesh by: determining first costs associated with the first portion ofthe warping mesh, where the first costs include costs associated withone or more face-related transformations of at least the first imagearea to correct one or more geometric distortions of the first region ofinterest as represented in the image; determining an optimized meshbased on an optimization of the cost function for the warping mesh; andmodifying the first image area of the image based on the optimized mesh.

In another aspect, an article of manufacture is provided. The article ofmanufacture includes one or more computer readable media havingcomputer-readable instructions stored thereon that, when executed by oneor more processors of a computing device, cause the computing device tocarry out functions. The functions include: receiving image datarepresenting an image; determining a first image area corresponding to afirst region of interest in the image; determining a warping mesh forthe image; determining a first portion of the warping mesh associatedwith the first image area; determining a cost function for the warpingmesh by: determining first costs associated with the first portion ofthe warping mesh, where the first costs include costs associated withone or more face-related transformations of at least the first imagearea to correct one or more geometric distortions of the first region ofinterest as represented in the image; determining an optimized meshbased on an optimization of the cost function for the warping mesh; andmodifying the first image area of the image based on the optimized mesh.

The foregoing summary is illustrative only and is not intended to be inany way limiting. In addition to the illustrative aspects, embodiments,and features described above, further aspects, embodiments, and featureswill become apparent by reference to the figures and the followingdetailed description and the accompanying drawings.

BRIEF DESCRIPTION OF THE FIGURES

FIG. 1 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 2 shows an input image with a face box and an extended face box, inaccordance with an example embodiment.

FIG. 3 shows an image mask for the input image of FIG. 2, in accordancewith an example embodiment.

FIG. 4 shows a warping mesh for the input image of FIG. 2, in accordancewith an example embodiment.

FIG. 5 shows an optimized mesh for the input image of FIG. 2, inaccordance with an example embodiment.

FIG. 6 shows an output image that includes facial corrections of theinput image of FIG. 2, in accordance with an example embodiment.

FIG. 7 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 8 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 9 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 10 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 11 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 12 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 13 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 14 illustrates a scenario where an input image representing twofaces has both faces corrected in a corresponding output image, inaccordance with an example embodiment.

FIG. 15 illustrates a scenario where an input image representing fourfaces has three of the four faces corrected in a corresponding outputimage, in accordance with an example embodiment.

FIG. 16 illustrates a scenario where a computing device displays aninput image and a control that, when selected, causes the computingdevice to generate a corresponding output image 1550 that includescorrections of faces represented in the input image, in accordance withan example embodiment.

FIG. 17 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 18 illustrates phases of a machine learning model, in accordancewith an example embodiment.

FIG. 19 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 20A illustrates a neural network, in accordance with an exampleembodiment.

FIG. 20B illustrates an encoder bottleneck with down-sample function ofthe neural network of FIG. 20A, in accordance with an exampleembodiment.

FIG. 20C illustrates an encoder bottleneck function of the neuralnetwork of FIG. 20A, in accordance with an example embodiment.

FIG. 20D illustrates an encoder bottleneck with down-sample and max-poolfunction of the neural network of FIG. 20A, in accordance with anexample embodiment.

FIG. 20E illustrates a decoder bottleneck with up-sample function of theneural network of FIG. 20A, in accordance with an example embodiment.

FIG. 20F illustrates a decoder bottleneck function of the neural networkof FIG. 20A, in accordance with an example embodiment.

FIG. 20G illustrates a decoder bottleneck with max-unpool function ofthe neural network of FIG. 20A, in accordance with an exampleembodiment.

FIG. 21 is a flowchart of a method, in accordance with an exampleembodiment.

FIG. 22 depicts a distributed computing architecture, in accordance withan example embodiment.

FIG. 23 is a functional block diagram of an example computing device, inaccordance with an example embodiment.

FIG. 24 is a flowchart of a method, in accordance with an exampleembodiment.

DETAILED DESCRIPTION

When objects are photographed, a three dimensional environment isreproduced as a two dimensional image. Accordingly, three dimensionalpoints in space are projected onto a two dimensional coordinate system.Various distortions may occur as a result of such projections. Forexample, perspective distortion can occur when an angle of view of fromwhich an image was captured differs from the angle of view at which theimage is viewed, and can result in a distortion in the relativeappearance of objects at varying distances from the imaging device.Perspective distortion artifacts can be particularly noticeable in theuse of Wide Field of View (WFOV) imaging systems, which can include WFOVlenses and/or WFOV sensors. Accordingly, the advantages of WFOV imagingsystems—which are often present on mobile computing devices or otherdevices; e.g., smartphones, flip phones, tablets—are often associatedwith drawbacks in image fidelity. Such an effect can often beparticularly pronounced for objects in the periphery of an image.

As a result, when human faces and/or other objects are photographed,particularly in the peripheral regions of a resulting photograph orother image, the human faces and/or other objects may exhibit stretchedand skewed features as a result of perspective distortion. This is atechnical consequence of the imaging system and can be disadvantageousin terms of image fidelity and cause a reduction in image quality. Inparticular, distortions of human faces can be particularly noticeableand thus represent a meaningful degradation in image quality even wheresuch distortions are relatively minor. That is, perspective distortioncan cause disagreeable distortions of human faces, resulting in negativeimpacts on user experiences. Perspective distortion can causedisagreeable distortions of human faces, resulting in negative impactson user experiences.

As such, there is a problem with images (e.g., photographs, imagery invideo recordings) captured with perspective distortion artifacts ofobjects such as faces, including human faces. Herein are describedtechniques and related apparatus to correct these perspective distortionartifacts in photographs and/or other images. The herein-describedtechniques and related apparatus can help correct these artifacts usingone or more projections. More particularly, facial regions of one ormore input images; that is, regions of input image(s) that representfaces, can be locally corrected using a first projection and regions ofinput image(s) outside of facial regions can be corrected using a secondprojection. For example, the first projection can be a stereographicprojection and the second projection can be a perspective projection.The first projection and/or the second projection can be embodied in amesh. Also, one or more corrected images that reflect the correctionsmade to the one or more input images using the mesh, the firstprojection, and/or the second projection can be generated, displayed,transmitted, and/or otherwise produced—in some cases, a corrected imagecan reflect corrections made using the mesh, the first projection,and/or the second projection to most, if not all, pixels of acorresponding input image. As an example, these herein-describedtechniques can be embodied in a software application of a mobilecomputing device.

Other techniques have been used to correct images. In some cases,fish-eye lenses and/or related software are utilized to globally map animage in an attempt to correct perspective distortion artifacts.However, fish-eye lenses and/or related software are not able to producestraight lines, and render a resulting image with a curvy appearance.The herein-described techniques and related apparatus can correctperspective distortion artifacts while maintaining straight lines inimages, thereby creating few, if any, additional artifacts in aperspective-distortion corrected image. Further, a software applicationcan perform the herein-described techniques efficiently on a mobilecomputing device.

In particular, herein-described techniques rely on a concept of locallyblending conformal projections on facial regions of an image, where afacial region is a region of an image that represents one or more faces.Conformal projections can include angle-preserving projections, such asstereographic projections which project a sphere onto a plane whilepreserving angles where curves meet. The rest of the image; that is, theportion of the image outside of the facial regions, can be renderedusing a perspective projection that preserves straight lines. However, aconformal projection applied to an entire image distorts the shapes andcurvatures of rigid objects in the entire image. To avoid thesedistortions of shapes and curvatures of objects, the herein-describedtechniques apply conformal projections locally to facial regions. Then,to address the shape/curvature distortions outside of facial regions,straightness-preserving perspective transformations are used on the restof the image. The resulting image correction technique combines theconformal projections on facial regions of an image and the perspectiveprojection on the rest of the image.

In some examples, the herein-described techniques may be applied tocorrect images in a successive image stream (e.g., a video stream). Forexample, the herein-described techniques can be utilized in a real-timeface distortion rectification system that corrects temporal flickeringand/or wobbling between successive images in a stream. Techniques thatinvolve a neural network for real-time subject segmentation and atemporal coherence term to adjust for previous images in a stream areprovided in the description herein.

In some examples, the herein-described techniques can be utilized withminimal or no user input. For example, the herein-described techniquescan be utilized without requesting a user identify facial regions,lines, or other aspects of an image and without requesting userspecification of terms utilized in calculations of the herein-describedtechniques. Rather, as discussed below, the herein-described techniquescan be utilized without such user inputs on aspects of the image and onterms used in the herein-described calculations, and therefore can beutilized in automatic image correction applications. Also, theherein-described techniques can be utilized without user input tocorrect a series of images, such as a series of images in a videorecording. Thus, the herein-described techniques can be beneficiallyutilized to correct facial regions in still images and/or in images ofvideo recordings without requiring user input. Of course, variations ofthe herein-described techniques with some user input are possible aswell.

Techniques and Apparatus for Correcting Perspective Distortion in Images

A mesh optimization problem can be solved on a warping mesh to combineconformal projections on facial regions of an image and perspectiveprojections on the rest of the image. Then, an output image can berendered by warping a related input image with perspective distortionsusing an optimized mesh that solves the mesh optimization problem.

In some examples, the following procedure, which is related to method100 discussed below in the context of FIG. 1, can be used to generate acorrected output image O that corrects some or all of the perspectivedistortions in a corresponding input image I:

-   -   1. Triggering conditions of input image I can be checked. For        example, such triggering conditions can relate to the        representation of faces (e.g., human faces, animal faces) and/or        other objects the sizes of representations of such faces and/or        objects, and conformality costs related to the representations        of faces and/or objects. Other triggering conditions are        possible as well.    -   2. One or more facial masks corresponding to facial region(s) of        image I can be determined. A union of the facial masks can be        used as a combination of the portions of image I that correspond        to facial region(s). In some examples where artifacts of objects        other than faces are to be corrected, the facial masks and        corresponding facial regions can be replaced and/or augmented        with one or more masks for the objects other than faces and/or        one or more corresponding object regions of image I for the        objects other than faces.    -   3. Scale factors related to the facial region(s) can be        estimated. For example, facial regions of image I can be        associated with a first type of transformation or other        processing technique, and non-facial regions of image I can be        associated with a second type of transformation or other        processing technique—then, a scale factor can represent a ratio        of an area of a portion P of image I processed with the first        type of transformation to an area of the portion P of image I        processed with the second type of transformation (or vice        versa). Other scale factors are possible as well.    -   4. A mesh optimization problem can be formulated as an        optimization equation with energy terms in a warping mesh v. For        example, the mesh optimization problem can be a minimization        problem to minimize the energy terms represented in the warping        mesh v. Other mesh optimization problems are possible as well.    -   5. Boundary conditions can be imposed on the warping mesh v. In        some examples, boundary conditions are not imposed.    -   6. The mesh optimization problem on the warping mesh v can be        numerically solved and that solution can be normalized to yield        an optimal mesh v′.    -   7. The optimal mesh v′ can be resampled to generate an inverse        mesh z.    -   8. The output image O can be generated by sampling pixels of        input image I based on coordinates generated using inverse        mesh z. Output image O can correct input image I by reducing or        eliminating the artifacts related to perspective distortions in        input image I.        Other procedures are possible for use in generating a corrected        output image O that corrects some or all of the perspective        distortions in a corresponding input image I.

FIG. 1 is a flowchart of a method 100, in accordance with an exampleembodiment. Method 100, which is related to the procedure describedabove, can generate a corrected output image O that corrects perspectivedistortions in a corresponding input image I. Method 100 can be carriedout by a computing device, such as computing device 2300 describedbelow.

Method 100 can begin at block 110, where the computing device canreceive an input image I having width W(I) and height H(I). Also, thecomputing device can determine N, which is a number of faces representedby image I whose sizes are larger than a threshold size. Detailedprocedures related to block 110 are described below in the context ofFIG. 7.

At block 120, the computing device can determine N face boxes FB_(k) forthe N faces in input image I, where k ranges from 1 to N. A face box foran image can indicate a region of the image that represents a face, suchas a human face. In some examples, the face box can have a square orrectangular shape. In other examples, the face box can have a differentshape than a square or rectangle; e.g., an oval or elliptical shape, atriangular shape, a hexagonal shape, etc.

The computing device can extend each face box FB_(k), 1≤k≤N, of the Nface boxes as necessary to contain facial landmarks of the k^(th) face.A facial landmark of a face can indicate location on the face of aparticular feature of the face; such features of a face can include, butare not limited to: a top of a head with the face, hair of the face, aforehead of the face, an eye of the face, a nose of the face, a nostrilof the face, a lip of the face, a mouth of the face, a chin of the face,a tongue of a face, teeth of the face, a facial expression of the face,a dimple on the face, a beauty mark and/or other mark on the face, and aneck holding up the face. Detailed procedures related to block 120 aredescribed below in the context of FIG. 8.

As an example related to block 120, FIG. 2 shows an example input image200 that includes face 210 in front of wall 240, where face 210 islocated near a right edge of image 200. FIG. 2 shows that face 210 ispartially surrounded by initial face box 212. That is, in the exampleinput image 200 shown in FIG. 2, N is equal to 1, and face box 212 canbe considered to be FB₁ before extension. Then, facial landmarks can bedetected in image 200—such facial landmarks are shown in FIG. 2 as whitecircles and include facial landmark 220 near a top of face 210 andfacial landmark 222 at lower right of face 210. Face box 212 includesfacial landmark 222 but does not include facial landmark 220. Thus, atblock 120, the computing device can extend face box 212 to include allfacial landmarks found for face 210—the resulting extended face box isshown in FIG. 2 as extended face box 230.

At block 130, the computing device can, for each face box FB_(k), 1≤k≤N,of the N face boxes, compute a segmentation mask M_(k) in input image I.Then, the computing device can determine an image mask M as a union ofall segmentation masks M_(k).

As an example related to block 130, FIG. 3 shows image mask 300, whichrepresents segmentation mask M₁ for extended face box FB₁ that arerespectively represented as segmentation mask 310 and extended face box230. Segmentation mask 310 is a mask representing face 210, asillustrated by facial landmarks of face 210 including facial landmarks220 and 222.

In some examples, at block 130 the computing device can determine ifinput image I includes lens distortion. If image I does include lensdistortion, the lens distortion can be corrected by warping image maskM.

At block 140, the computing device can create at least one warping meshv having NR×NC vertices for image I, where each of NR and NC is greaterthan 0. As an example related to block 140, FIG. 4 shows warping mesh400, where NR=75=a number of rows of warping mesh 400, and NC=100=anumber of columns of warping mesh 400.

At block 150, the computing device can update warping mesh v with costsassociated with performing one or more face-related transformations forthe N faces in image I in locations of mesh v corresponding to mask M.For example, the costs associated with performing one or moreface-related transformations can be termed face-related costs. Theface-related transformation(s) can correct(s) one or more geometricdistortions of at least one of the N faces. Detailed procedures relatedto block 150 are described below in the context of FIG. 9.

At block 160, the computing device can update mesh v with costsassociated with performing one or more edge-related transformations forpreserving straightness of edges of the image modified at least by theone or more face-related transformations and with costs for boundariesof warping mesh v. For example, the costs associated with performing oneor more edge-related transformations can be termed edge-related costs.Detailed procedures related to block 160 are described below in thecontext of FIG. 10. In some examples, one or more projectiontransformations can combine both the one or more face-relatedtransformations and the one or more edge-related transformations; insome of these examples, the face-related costs and the edge-relatedcosts can be combined as projection costs (corresponding to the combinedprojection transformations).

At block 170, the computing device can determine optimized mesh v′ basedon a numerical optimization, such as a minimization, of cost terms ofvertices of warping mesh v as updated in blocks 150 and 160. Detailedprocedures related to block 170 are described below in the context ofFIG. 11.

As an example related to block 170, FIG. 5 shows optimized mesh 500,which shows warping mesh 400 updated and optimized with a face-relatedmesh portion 510 associated with face 210, extended face box 230, andsegmentation mask 310. Face-related mesh portion 510 has been updatedwith costs associated with performing face-related transformations forface 210 in input image 200. Further, the costs associated withperforming face-related transformations have been optimized; e.g.,minimized using numerical optimization. The face-related transformationsare reflected in FIG. 5 as deformations of optimized mesh 500 withinface-related mesh portion 510. As with warping mesh 400, optimized mesh500 has a number of rows NR=75 a number of columns NC=100.

At block 180, the computing device can determine inverse mesh z byresampling optimized mesh v′. Detailed procedures related to block 180are described below in the context of FIG. 12.

At block 190, the computing device can determine output image O by atleast: for each pixel P(O) of image O, update P(O) based on a sample ofimage I taken at sampling coordinates determined based on inverse meshz. Detailed procedures related to block 190 are described below in thecontext of FIG. 13.

After output image O is determined, the computing device can outputimage O; e.g., display part or all of image O, store part or all ofimage O in volatile and/or non-volatile memory; communicate part or allof image O to one or more other computing devices, print image O topaper, etc.

As an example related to block 190, FIG. 6 shows output image 600 thatcorrects input image 200. In particular, face 610 in output image 600has been rotated and scaled in comparison to face 210 of input image200, where face 610 has been rotated and scaled by the face-relatedtransformations discussed above in the context of at least block 150.Output image 600 also shows that straight lines have been preserved;e.g., straight lines outlining doors, door frames, etc. with respect towall 640 as represented in output image 600 are also shown as straightlines with respect to wall 240 represented in input image 200. Otherstraight lines and angles between straight lines outside of extendedface-box 230 are the same in both input image 200 and output image 600.Thus, output image 600 has been rendered by the procedures of method 100that involve warping input image 200 to correct perspective distortionswithin extended face-box 230. Further, as shown by comparing images 200and 600, method 100 did not add (at least) straight-line related visualartifacts to input image 200 while generating output image 600.

Method 100 can be configured with privacy controls to ensure privacy ofone or more persons whose faces are present in the images processed bymethod 100. For example, the computing device can obtain explicitpermission from each person whose face is represented by a face boxFB_(k)—the computing device can present the faces in face boxes FB_(k),where k ranges from 1 to N, perhaps after the face boxes have beenextended in block 120. Then, permission can be obtained to process inputimage I from each person whose face is in face boxes FB_(k) beforeproceeding with the remainder of method 100; i.e., the computing devicecan display the face boxes FB_(k) to request approval from each personwhose face is in a displayed face box.

In other examples, the one or more persons whose faces are in an imagecan give prior approval to perform method 100 before input image I isreceived at block 110, and computing device can verify that approval asneeded before performing method 100. In still other examples, suchpermissions may be implicit; e.g., if the owner of the computing devicecaptures their own face and only their own face in a “selfie” image andthen requests image correction using method 100, the owner's permissionto proceed to perform method 100 solely for their own face may beinferred by their request for image correction on the selfie.Combinations of these privacy-related techniques and/or other techniquesfor ensuring privacy of persons whose faces are captured in input imageI and/or other images are possible as well.

FIG. 7 is a flowchart of a method for the procedures of block 110 ofmethod 100, in accordance with an example embodiment. For example, thecomputing device performing method 100 can perform at least some of theprocedures of blocks 710, 720, 730, 740, 750, 760, 770, 772, 774, 776,780, 782, 784, and 790, while performing the procedures of block 120 ofmethod 100.

At block 710, the computing device can receive input image I havingwidth W(I) and height H(I). The computing device can determine N, whichis a number of faces, such as but not limited to a number of humanfaces, represented by image I. For example, input image 200 of FIG. 2represents N=1 human face. The computing device can determine a minimumconformality cost CCmin for a face, where conformality costs for facesare discussed in more detail below in the context of at least blocks 774and 776. The computing device can let a value N1 be equal to N.

At block 720, the computing device can determine face boxes FB_(k),1≤k≤N for the N faces. To determine N and/or some or all of face boxesFB₁, FB₂ . . . FB_(N), the computing device can utilize face detectionsoftware that locates and/or counts faces in image I and/or computesface boxes for faces detected in image I. The computing device can let avalue k be equal to 1.

At block 730, the computing device can determine whether a size, such asan area, of face box FB_(k) is greater than a threshold size of a facebox TS. If the computing device determines that the size of face boxFB_(k) is greater than TS, then the computing device can proceed toblock 750. Otherwise, the computing device can determine that the sizeof face box FB_(k) is less than or equal to TS, and can proceed to block740.

At block 740, the computing device can discard face box FB_(k). Bydiscarding face box FB_(k), the computing device effectively will nolonger process a facial portion of the image associated with face boxFB_(k) as a face. Then, the computing device can decrement the value ofN by one; that is, the computing device can let N=N−1.

At block 750, the computing device can increment the value of k by 1;that is, the computing device can let k=k+1.

At block 760, the computing device can determine whether k is greaterthan N1. If the computing device determines that k is greater than N1,then the computing device can proceed to block 770. Otherwise, thecomputing device can determine that k is less than or equal to N1, andcan proceed to block 730.

At block 770, the computing device can determine whether N is less thanor equal to 0. If the computing device determines that N is less than orequal to 0, then no faces in image I have corresponding face boxes thatexceed threshold size TS, and so the computing device can proceed toblock 790. Otherwise, the computing device can determine that N isgreater than 0, and can proceed to block 772.

At block 772, the computing device can set the value of k equal to 1.

At block 774, the computing device can determine a maximum conformalitycost CC_(k) of the four corners C1, C2, C3, and C4 of face box FB_(k).The conformality cost CC_(k) for face box FB_(k) can be determined as aweighted sum of squares of differences of coordinates of the corners C1,C2, C3, and C4 of face box FB_(k), where a difference of coordinates ofthe corners in at least one dimension are further weighted by a valuethat is based on the area of face box FB_(k).

At block 776, the computing device can determine whether conformalitycost CC_(k) for face box FB_(k) is less than the minimum conformalitycost CCmin. If the computing device determines that CC_(k) is less thanCCmin, then the computing device can proceed to block 782. Otherwise,the computing device can determine that CC_(k) is greater than or equalto CCmin and the computing device can proceed to block 780.

At block 780, the computing device can proceed with the remainder ofmethod 100; i.e., complete the procedures of block 110 of method 100 andcontinue method 100 by beginning performance of the procedures of block120 of method 100.

At block 782, the computing device can increment the value of k by 1;that is, the computing device can let k=k+1.

At block 784, the computing device can determine whether k is greaterthan N. If the computing device determines that k is greater than N,then the computing device can proceed to block 790. Otherwise, thecomputing device can determine that k is less than or equal to N, andcan proceed to block 774.

At block 790, the computing device can copy input image I to outputimage O; i.e., generate a copy of input image I as output image O. Thecomputing device can exit method 100 where image O is an output ofmethod 100.

FIG. 8 is a flowchart of a method for the procedures of block 120 ofmethod 100, in accordance with an example embodiment. For example, thecomputing device performing method 100 can perform some or all of theprocedures of blocks 800, 810, 820, 830, 840, 850, and 860 whileperforming the procedures of block 120 of method 100.

At block 800, the computing device can let and/or initialize a value kto be equal to 1.

At block 810, the computing device can determine one or more faciallandmarks FL_(k) for face k in image I.

At block 820, the computing device can determine whether face box FB_(k)for face k contains all of facial landmark(s) FL_(k). For example, thecomputing device can determine whether coordinates of each faciallandmark FL are inside or outside face box FB_(k). If the coordinates ofall of facial landmark(s) FL_(k) are inside face box FB_(k), then thecomputing device can determine that face box FB_(k) contains all offacial landmark(s) FL_(k) and so encloses an area of image I thatrepresents face k, and the computing device can proceed to block 840.Otherwise, the computing device can determine that face box FB_(k) doesnot contain all of facial landmark(s) FL_(k) and the computing devicecan proceed to block 830.

At block 830, the computing device can extend face box FB_(k) to containall of facial landmark(s) FL_(k). As such, after extension at block 830,face box FB_(k) encloses an area of image I that represents face k

At block 840, the computing device can increment the value of k by 1;that is, the computing device can let k=k+1.

At block 850, the computing device can determine whether k is greaterthan N. If the computing device determines that k is greater than N,then the computing device can proceed to block 860. Otherwise, thecomputing device can determine that k is less than or equal to N, andcan proceed to block 810.

At block 860, the computing device can proceed with the remainder ofmethod 100; i.e., complete the procedures of block 120 of method 100 andcontinue method 100 by beginning performance of the procedures of block130 of method 100.

FIG. 9 is a flowchart of a method for the procedures of block 150 ofmethod 100, in accordance with an example embodiment. For example, thecomputing device performing method 100 can perform some or all of theprocedures of blocks 900, 910, 920, 930, 940, 950, 960, 970, and 980while performing the procedures of block 150 of method 100.

At block 900, the computing device can let and/or initialize a value kto be equal to 1.

At block 910, the computing device can compute an area SA_(k) of facebox FB_(k) mapped into stereographic space and compute another areaPA_(k) of face box FB_(k) mapped into perspective space. Then, thecomputing device can compute native scale factor NSF_(k) for face k asNSF_(k)=SA_(k)/PA_(k). The native scale factor NSF_(k) can indicate howa size of face k, which is enclosed by face box FB_(k), changes afterstereographic projection.

At block 920, the computing device can create warping meshes u and v,where each of warping meshes u and v have NR×NC vertices, whereNR=number of rows is greater than 0, and where NC=number of rows isgreater than 0. For example, NR=100, and NC=75, and, in this example,each of meshes u and v would have NR*NC=7500 vertices. Warping mesh vcan be a mesh (of vertices) over image I, perhaps after image I has beenlens corrected. Warping mesh u can be a warping mesh (of vertices) overa stereographic projection of image I. Other examples of warping mesh uand/or warping mesh v are possible as well.

At block 930, the computing device can associate each vertex in mesh vwith face scale cost term FSCT_(k) for face k. The face scale cost termFSCT_(k) can represent an amount of scaling for face k to be performedto correct distortions of face k as represented in image I. FSCT_(k) canbe computed as FSCT_(k)=W_(f)*a_(k)−1/NSF_(k)|², where W_(s) is aweighting term for facial scaling, where NSF_(k) is the native scalefactor term for face k discussed above in the context of block 910, andwhere a_(k) represents scaling of face k provided by transformationmatrix S_(k), which is discussed immediately below.

At block 940, the computing device can set up and/or initialize twoimplicit variables for face k: transformation matrix S_(k) andtranslation vector t_(k). S_(k) can include a transformation matrixrepresenting scaling and/or rotation of face k and t_(k) can include atranslation vector representing translation of face k. For example,S_(k) can include a per-face rigid transformation matrix [a_(k)_b_(k);−b_(k) a_(k)], representing the combination of scaling transformationa_(k) and rotation transformation b_(k) for face k, and t_(k) caninclude a per-face translation vector [tx_(k), ty_(k)], with tx andty_(k) representing respective x-coordinate and y-coordinatetranslations of face k. The scaling, rotation, and/or translation offace k represented by matrix S_(k) and vector t_(k) can betransformations, such as affine transformations, that can correct one ormore geometric distortions of face k as represented in image I.

At block 950, the computing device can formulate costs for each vertex Vin warping mesh v_(k) by performing the following functions: (1)determine corresponding vertex U in mesh u, and (2) associate vertex Vwith facial transformation cost term FTCT_(k). The transformation costterm FTCT_(k) can represent an amount of transformations for face k tobe performed to correct distortions of face k as represented in image I.FTCT_(k) can be computed as FTCT_(k)=W_(s)*|V−S_(k)*U−t_(k)|², whereW_(s) is a weighting term for facial transformations, S_(k) is theimplicit variable and transformation matrix discussed above in thecontext of block 940, and t_(k) is the implicit variable and translationvector discussed above in the context of block 940.

At block 960, the computing device can increment the value of k by 1;that is, the computing device can let k=k+1.

At block 970, the computing device can determine whether k is greaterthan N. If the computing device determines that k is greater than N,then the computing device can proceed to block 980. Otherwise, thecomputing device can determine that k is less than or equal to N, andcan proceed to block 910.

At block 980, the computing device can proceed with the remainder ofmethod 100; i.e., complete the procedures of block 150 of method 100 andcontinue method 100 by beginning performance of the procedures of block160 of method 100.

FIG. 10 is a flowchart of a method for the procedures of block 160 ofmethod 100, in accordance with an example embodiment. For example, thecomputing device performing method 100 can perform some or all of theprocedures of blocks 1000, 1010, 1020, 1030, 1040, 1042, 1050, 1060,1070, 1080, and 1090 while performing the procedures of block 160 ofmethod 100.

At block 1000, the computing device can let and/or initialize a value eto be equal to 1 and let and/or initialize a value NE to be equal to anumber of edges and/or other lines represented in image I. For example,a line-detecting algorithm can be used to detect edges and/or otherlines represented in image I, and the value NE can be set to the numberof edges and/or other lines detected in image I. Other techniques fordetermining the value NE are possible as well.

At block 1010, the computing device can set a value E to be equal toedge e of image I, where E is associated with vertices V_(i) and V_(j)in mesh v, and where i≠j.

At block 1020, the computing device can associate edge E with an edgecost term ECT that represents a cost associated with maintaining edge E.ECT can be calculated as ECT=W_(r)*|E|², where |E|² represents a lengthof edge E, and where W_(r) is a regularization weighting term.

At block 1030, the computing device can associate edge E with an edgebending term EB(E) that represents a cost associated with bending edge Eafter edge E has been transformed. EB(E) can equal one of two values,depending on a horizontal or vertical orientation of edge E. Morespecifically, EB(E) can be determined as either:EB(E)=W _(b) *|V _(i) ,y+V _(j) ,y| ², if edge E is horizontal; orEB(E)=W _(b) *|V _(i) ,x+V _(j) ,x| ², if edge E is vertical.where W_(b) can be a bending weighting term.

At block 1040, the computing device can increment the value of e by 1;that is, the computing device can let e=e+1.

At block 1042, the computing device can determine whether e is greaterthan NE. If the computing device determines that e is greater than NE,then the computing device can proceed to block 1050. Otherwise, thecomputing device can determine that e is less than or equal to NE, andcan proceed to block 1010.

At block 1050, the computing device can associate each vertex V_(b) on aborder of mesh v with a boundary cost term BCT. BCT can be calculated asBCT=W_(b)*d(V_(b)), where d(V_(b)) is a perpendicular distance betweenvertex V_(b) and a border of mesh v, and where W_(b) can be the bendingweighting term discussed above in the context of block 1030.

At block 1060, the computing device can extend mesh v by a number NBDRYof vertices on each side, NBDRY>0. For example, NBDRY can be an integervalue, such as 1, 2, 3, 4, or another integer value. For each vertexthat is added to warping mesh v by extend the mesh by NBDRY vertices,the computing device can fix a dimension of the vertex to beperpendicular to a border of image I. Then, the computing device canupdate number of rows NR of mesh v and the number of columns NC based onNBDRY; e.g., NR=NR+NBDRY and NC=NC+NBDRY.

At block 1070, the computing device can determine whether asymmetriccosts are to be used in method 100. For example, a variable, value, flagor other similar data item ACFLAG can be set to a first value (e.g.,one) if asymmetric costs are to be used in method 100, and can be set toa second value (e.g., zero) if asymmetric costs are not to be used inmethod 100. Then, the computing device can examine the value of ACFLAGto determine whether asymmetric costs are to be used in method 100. Ifthe computing device determines that asymmetric costs are to be used inmethod 100, then the computing device can proceed to block 1080.Otherwise, the computing device can determine that asymmetric costs arenot to be used in method 100 and can proceed to block 1090.

At block 1080, the computing device can, for each vertex V, originallyin mesh v (i.e., a vertex of mesh v that was not added at block 1060),associate vertex V, with outside-mesh indicator function OMI(V_(i))=0.For each vertex V_(j) not originally in mesh v (i.e., a vertex of mesh vthat was added at block 1060), the computing device can associate V_(j)with outside-mesh indicator function OMI(V_(j))=1.

At block 1090, the computing device can proceed with the remainder ofmethod 100; i.e., complete the procedures of block 160 of method 100 andcontinue method 100 by beginning performance of the procedures of block170 of method 100.

Other cost functions than those described in the context of FIGS. 9 and10 are possible as well. Also, in some examples, the relative weights ofthe cost functions can be modified and/or the stereographic projectionused in creating warping mesh u can be replaced with one or more otherprojections.

FIG. 11 is a flowchart of a method for the procedures of block 170 ofmethod 100, in accordance with an example embodiment. For example, thecomputing device performing method 100 can perform some or all of theprocedures of blocks 1100, 1110, 1120, 1130, 1140, 1150, 1160, 1170, and1180 while performing the procedures of block 170 of method 100.

At block 1100, the computing device can determine whether asymmetriccosts are to be used in method 100. Techniques for determining whetherasymmetric costs are to be used in method 100 are discussed above in thecontext of block 1070. If the computing device determines thatasymmetric costs are to be used in method 100, then the computing devicecan proceed to block 1110. Otherwise, the computing device can determinethat asymmetric costs are not to be used in method 100 and can proceedto block 1120.

At block 1110, the computing device can use a coarse-to-fine techniqueinvolving LevelNum levels, LevelNum>1, to initialize optimized mesh v′.To carry out the coarse-to-fine technique, the computing device can: (a)at a coarsest level (e.g., level 1), initialize optimized mesh V′ basedon an interpolation of a stereographic projection and a perspectiveprojection for each face box FB_(k), 1≤k≤N; and (b) for each finer levelN, 2≤N≤LevelNum; upsample initialized mesh V′ from level N−1.

At block 1120, the computing device can initialize optimized mesh V′ bycopying warping mesh V to optimized mesh V′

At block 1130, the computing device can obtain optimized mesh V′ anddetermine values for implicit variables Sk and tk by performingnumerical minimization of sums of costs associated with vertices ofinitialized mesh V′, where S_(k) is the implicit variable andtransformation matrix discussed above at least in the context of block940, and t_(k) is the implicit variable and translation vector discussedabove at least in the context of block 940.

An example numerical solver that can be used to perform the numericalminimization of sums of costs associated with vertices of initializedmesh V′ is the Ceres Solver described on the Internet atceres-solver.org.

At block 1140, the computing device can compute or otherwise determinedh_(max), dh_(min), dv_(max), dv_(min) values of mesh V′. The dh_(max)value can be determined as dh_(max)=max(v′_(i), x) among vertices v′_(i)on left border of mesh V′. The dh_(min) value can be determined asdh_(min)=min(v′_(i), x) among vertices v′_(i) on right border of meshV′. The dv_(max) value can be determined as dv_(max)=max(v′_(i), x)among vertices v′_(i) on top border of mesh V′. The dv_(min) value canbe determined as dv_(min)=(v′_(i), x) among vertices v′_(i) on bottomborder of mesh V′.

At block 1150, the computing device can determine a scale vector s_(V′),where the scale vector s_(V′)=[s_(x), s_(y)]=[W(I),H(I)]/[dh_(min)−dh_(max), dv_(min)−dv_(max)], where W(I) can be thewidth of image I, and H(I) can be the height of image I.

At block 1160, the computing device can determine an offset vectoro_(V′), where offset vector o_(V′)=[o_(x), o_(y)]=[dh_(max), dv_(max)].

At block 1170, the computing device can modulate each vertex v′₁ of meshV′ by determining v′₁=s_(V′)*o_(V′)).

At block 1180, the computing device can proceed with the remainder ofmethod 100; i.e., complete the procedures of block 170 of method 100 andcontinue method 100 by beginning performance of the procedures of block180 of method 100.

FIG. 12 is a flowchart of a method for the procedures of block 180 ofmethod 100, in accordance with an example embodiment. For example, thecomputing device performing method 100 can perform some or all of theprocedures of blocks 1200, 1210, 1220, 1230, 1240, 1250, 1260, 1270,1280, and 1290 while performing the procedures of block 180 of method100. The flowchart of FIG. 12 illustrates a two-pass algorithm forresampling optimal mesh v′ to create an inverse mesh z. The first passof the two-pass algorithm involves the rows of optimized mesh v′ asindicated by blocks 1200, 1210, 1220, 1230, and 1240. The second pass ofthe two-pass algorithm involves the columns of optimized mesh v′ asindicated by blocks 1250, 1260, 1270, 1280, and 1290. Other resamplingtechniques to form inverse mesh z are possible as well.

At block 1200, the computing device can let and/or initialize a valueRNum equal to 1 and a value CNum equal to 1 Also, the computing devicecan let and/or initialize a value NRV to be equal to a number of rows inoptimized mesh v′ and can let and/or initialize a value NCV to be equalto a number of columns in optimized mesh v′.

At block 1210, the computing device can store an RNum^(th) row of v′ inbuffer BUF.

At block 1220, the computing device can interpolate the columncoordinates for the RNum^(th) row stored in BUF.

At block 1230, the computing device can increment the value of RNum by1; that is, the computing device can let RNum=RNum+1.

At block 1240, the computing device can determine whether the RNum valueis greater than NRV, whose value is a number of rows in optimized meshv′. If the computing device determines that the RNum value is greaterthan NRV, then the computing device can proceed to block 1250.Otherwise, the computing device can determine that the RNum value isless than or equal to NRV and can proceed to block 1210.

At block 1250, the computing device can copy a CNum^(th) column ofbuffer BUF to the CNum^(th) column of optimized mesh v′.

At block 1260, the computing device can interpolate row coordinates forthe CNum^(th) column of v′.

At block 1270, the computing device can increment the value of CNum by1; that is, the computing device can let CNum=CNum+1.

At block 1280, the computing device can determine whether the CNum valueis greater than NCV, whose value is a number of columns in optimizedmesh v′. If the computing device determines that the CNum value isgreater than NCV, then the computing device can proceed to block 1290.Otherwise, the computing device can determine that the RNum value isless than or equal to NRV and can proceed to block 1250.

At block 1290, the computing device can proceed with the remainder ofmethod 100; i.e., complete the procedures of block 180 of method 100 andcontinue method 100 by beginning performance of the procedures of block190 of method 100.

FIG. 13 is a flowchart of a method for the procedures of block 190 ofmethod 100, in accordance with an example embodiment.

For example, the computing device performing method 100 can perform someor all of the procedures of blocks 1300, 1310, 1320, 1330, 1340, 1350,1360, and 1370 while performing the procedures of block 190 of method100.

At block 1300, the computing device can let and/or initialize a valuePix equal to 1 and can let a value NumPix be equal to a number of pixelsin output image O.

At block 1310, the computing device can let P(O) be the Pix^(th) pixelin image O and can let Z_(i) be a number NumNbr of nearest neighbors toP(O) in inverse mesh z, where NumNbr is an integer greater than 0; e.g.,NumNbr can equal 1, 2, 3, 4, or another positive integer.

At block 1320, the computing device can set Coord(P(O)), which arecoordinates of pixel P(O) in perspective space, equal to aninterpolation of the NumNbr values of L.

At block 1330, the computing device can lookup Coord(P(O)) on alens-distorted space using a lens correction model to find coordinatesInCoords(P(O).

At block 1340, the computing device can let P(O) be equal to aresampling of input image I at coordinates represented byInCoords(P(O)). Then, the computing device can set a Pix^(th) pixel inimage O equal to P(O).

At block 1350, the computing device can increment the value of Pix by 1;that is, the computing device can let Pix=Pix+1.

At block 1360, the computing device can determine whether Pix is greaterthan NumPix. If the computing device determines that Pix is greater thanNumPix, then the computing device can proceed to block 1370. Otherwise,the computing device can determine that Pix is less than or equal toNumPix, and can proceed to block 1310.

At block 1370, the computing device can exit method 100, where image Ois an output of method 100.

Other techniques to utilize one or more meshes, such as meshes u, v, v′,and/or z, to warp an image, such as image I to form an output image,such as image O are possible as well.

FIG. 14 illustrates scenario 1400, where input image 1410 representingtwo faces 1420, 1430 has both faces corrected in a corresponding outputimage 1450, in accordance with an example embodiment. Scenario 1400begins with a computing device that is equipped with a camera; e.g., asmartphone with a camera, uses the camera to capture input image 1410.As shown at an upper portion of FIG. 14, input image 1410 is an image oftwo people in a work environment. As such, input image 1410 representstwo faces 1420, 1430 of the two people. Input image 1410 also representsregion 1440 of a ceiling in the work environment, where region 1440shows objects appearing to come together at various angles at or nearthe ceiling.

Scenario 1400 continues with the computing device receiving input image1410 from the camera, correcting input image 1410 using the techniquesof method 100 discussed above, and consequently generating output image1450. In particular, faces 1420, 1430 of input image 1410 are correctedto be respective faces 1470, 1480 of output image 1450 using affineand/or stereographic transformations as discussed above in the contextof method 100. For example, each of faces 1420, 1430 represented ininput image 1410 has been rotated and elongated (scaled) to have a morenatural shape as shown in respective faces 1470, 1480 of output image1450.

Additionally, region 1440 of input image 1410 is not corrected whilegenerating output image 1450. In particular, straight lines in region1440 of input image 1410 remain straight in corresponding region 1490 ofoutput image 1450. Further, lines that intersect in region 1440 of inputimage 1410 at various angles are shown in region 1490 of output image1450 as intersecting lines at the same, various angles. Thus, scenario1400 shows that the computing device can use method 100 to correct facesin images such as input image 1410 without changing straight linesbetween input image 1410 and output image 1450, other than straightlines and angles in facial regions of input image 1410.

FIG. 15 illustrates scenario 1500, where input image 1510 representingfour faces 1520, 1522, 1524, 1526 has three of the four faces correctedin corresponding output image 1550, in accordance with an exampleembodiment. Scenario 1500 begins with a computing device receiving inputimage 1510 from a camera. As shown at an upper portion of FIG. 15, inputimage 1510 is an image of at least four people in a work environment. Assuch, input image 1510 represents at least four faces 1520, 1522, 1524,1526 of at least four people.

Scenario 1500 continues with the computing device correcting input image1510 using the techniques of method 100 discussed above and consequentlygenerating output image 1550. In scenario 1500, face 1522 has anextended face box that is less than the threshold size TS discussedabove at least in the context of FIGS. 1 and 7. Therefore, the computingdevice does not correct face 1522 while generating output image 1550with corresponding face 1572. Also, each of the extended face boxes offaces 1520, 1524, and 1526 in input image 1510 are greater than thethreshold size TS. Scenario 1500 proceeds with the computing devicecorrecting only these three faces 1520, 1524, 1526 of input image 1510;e.g., using affine and/or stereographic transformations, as part ofusing the procedures of method 100 to generate output image 1550.

The correction of faces 1520, 1524, 1526 of input image 1510 transformsthe three faces to be respective faces 1570, 1574, 1576 of output image1550. e.g., the three faces 1520, 1524, 1526 while generating outputimage 1550 with corresponding face 1572. Additionally, straight linesand angles of intersection between straight lines in input image 1510(other than straight lines and angles in facial regions of input image1510) are not changed in output image 1550; e.g., angles of objectssuspended from a ceiling shown in input image 1510. Thus, scenario 1500illustrates use of method 100 to correct some, but not all, faceswithout changing straight lines in input image 1510 (outside of straightlines and angles in facial regions of input image 1510) as part ofgenerating output image 1550.

FIG. 16 illustrates scenario 1600, where computing device 1610 usesmethod 100 to correct input image 1510 as part of generating outputimage 1550, in accordance with an example embodiment. An upper portionof FIG. 16 shows that scenario 1600 begins with computing device 1610receiving input image 1510 from a camera and then displaying input image1510 and control 1620, where control 1620 includes a button labeled as“Apply Facial Correction”. Control 1620 when selected, causes computingdevice 1610 to use method 100 to correct an input image; e.g., inputimage 1510, as part of generating an output image; e.g., output image1550 In other scenarios, control 1620 can be represented by a graphicalobject of a graphical user interface (GUI) other than a button; e.g., anicon, a dialog. In still other scenarios, facial correctionfunctionality controlled using control 1620 can be controlled using oneor more non-GUI objects; e.g., keys on a keyboard, commands of a commandline interface.

Scenario 1600 proceeds with a user of computing device 1610 selectingcontrol 1620; e.g., clicking on control 1620 using a mouse; pressing alocation corresponding to control 1620 on a touch screen. After control1620 is selected, computing device 1610 uses method 100 to generateoutput image 1550 as discussed above in more detail the context of atleast FIGS. 1 and 15. After generating output image 1550, scenario 1600continues with computing device 1610 displaying output image 1550, asshown at a lower portion of FIG. 16. Output image 1550 has had some butnot all, of the faces in input image 1510 corrected without changingstraight lines outside of straight lines and angles in facial regions ofinput image 1510.

In some scenarios, a camera used to capture input image 1410, inputimage 1510, and/or other input imagery can be equipped with a Wide Fieldof View (WFOV) (or wide angle) lens and/or a WFOV sensor in order tofacilitate capture of a scene from relatively close proximity.

Techniques and Apparatus for Temporally Correcting PerspectiveDistortion

Generally speaking, the techniques described in FIGS. 1-16 are designedfor static input images. For example, method 100 can generate acorrected output image O that corrects perspective distortions in acorresponding input image I. However, when dealing with multiple,successive image frames (e.g., a video stream), applying the techniquesof FIGS. 1-16 to each individual image in a per-frame manner may causeproblems, such as temporal flickering and/or wobbling between successiveimages. Further, applying the techniques of FIGS. 1-16 on multiple,successive images may be computationally expensive (e.g., on the order990 ms/per image when applied via a mobile phone). If a goal ofcorrecting perspective distortion is to provide real time feedback to auser in the form of a “camera preview”, the high computational costs maypreclude the perspective distortion techniques of FIGS. 1-16 from beingincorporated into camera preview systems, which often require real-time,30 fps processing.

To address these and other issues, a real time perspective distortioncorrection procedure is provided. The proposed procedure relies onsimilar techniques as the mesh optimization problem described in FIGS.1-16, but provides the following additions: (1) a neural networkarchitecture for real-time subject segmentation, and (2) additionalcosts terms to establish smooth inter-frame warping. By using thetechniques described herein, temporal flickering, wobbling problems, andother coherence issues can be resolved and computational costs ofcorrecting perspective distortion can be reduced. Other benefits arealso possible.

It should be noted that since the techniques described below build ontechniques previously described in FIGS. 1-16, for the purpose ofbrevity, aspects of FIGS. 1-16 will be referred to and incorporated intothe description below. Systems and methods that are distinct to the realtime perspective distortion correction procedure will be detailed in thedescription herein.

FIG. 17 is a flowchart of method 1700, in accordance with an exampleembodiment. Method 1700 can generate a corrected output image O thatcorrects perspective distortions for a corresponding input image I attimestep t. Method 1700 can be carried out by a computing device, suchas computing device 2300 described below.

Method 1700 can begin at block 1710, where the computing device canreceive an input image I_(t) having width W(I_(t)) and height H(I_(t)).Input image I_(t) represents a single frame from a plurality of framesreceived by the computing device during a real time image stream. Inother words, input image is a frame captured at timestep t, which interms of the real time image stream sequence, is after a frame capturedat timestep t−1 and before a frame captured at timestep t+1. Also, thecomputing device can determine N_(t), which is a number of facesrepresented by image I at timestep t whose sizes are larger than athreshold size. In some embodiments, block 1710 can further involvedetermining face boxes FB_(k) for each of the N_(t) faces, where1≤k≤N_(t) and extending each face box FB_(k) as necessary to containfacial landmarks. Detailed procedures related to block 1700 werepreviously described above in the context of FIG. 7 and FIG. 8.

At block 1720, the computing device can apply a segmentation network todetermine a global segmentation mask M for input image I_(t) In someexamples, this involves applying the segmentation network on face boxesFB_(k) to determine individual segmentation masks M_(k) for each of theN_(t) faces, where 1≤k≤N_(t), and then using the computing device todetermine a global segmentation mask M as a union of all individualsegmentation masks M_(k). However, in other examples, block 1720 caninvolve applying the segmentation network directly on input image I_(t)to determine a global segmentation mask M. Detailed procedures relatedto block 1720 are described below in the context of FIG. 19. As anexample related to block 1720, FIG. 3 shows image mask 300, includingsegmentation mask 310. Segmentation mask 310 is a mask representing face210 from FIG. 2.

At block 1730, the computing device can create at least one warping meshv having NR×NC vertices for image I_(t), where each of NR and NC isgreater than 0. As an example related to block 1730, FIG. 4 showswarping mesh 400, where NR=33=a number of rows of warping mesh 400, andNC=25=a number of columns of warping mesh 400. In some examples, warpingmesh v may be initialized to an optimized mesh of a previous image(e.g., the optimized mesh from timestep t−1).

At block 1740, the computing device can update warping mesh v with costsassociated with performing one or more face-related transformations forthe N_(t) faces in image I_(t) in locations of mesh v corresponding tomask M. For example, the costs associated with performing one or moreface-related transformations can be termed face-related costs. Theface-related transformation(s) can correct(s) one or more geometricdistortions of at least one of the N_(t) faces. Detailed proceduresrelated to block 1740 are described below in the context of FIG. 21.

At block 1750, the computing device can update mesh v with costsassociated with performing one or more edge-related transformations forpreserving straightness of edges of the image modified at least by theone or more face-related transformations and with costs for boundariesof warping mesh v. For example, the costs associated with performing oneor more edge-related transformations can be termed edge-related costs.Detailed procedures related to block 1750 were previously described inthe context of FIG. 10. In some examples, one or more projectiontransformations can combine both the one or more face-relatedtransformations and the one or more edge-related transformations; insome of these examples, the face-related costs and the edge-relatedcosts can be combined as projection costs (corresponding to the combinedprojection transformations).

At block 1760, the computing device can determine optimized mesh v′based on a numerical optimization, such as a minimization, of cost termsof vertices of warping mesh v as updated in blocks 1740 and 1750.Detailed procedures related to block 1760 were previously described inthe context of FIG. 11.

At block 1770, the computing device can determine inverse mesh z byresampling optimized mesh v′. Detailed procedures related to block 1770were previously described in the context of FIG. 12.

At block 1780, the computing device can determine output image O by atleast: for each pixel P(O) of image O, update P(O) based on a sample ofimage I_(t) taken at sampling coordinates determined based on inversemesh z. Detailed procedures related to block 1780 were previouslydescribed in the context of FIG. 13.

As an example related to block 1780, FIG. 6 shows output image 600 thatcorrects input image 200. In particular, face 610 in output image 600has been rotated and scaled in comparison to face 210 of input image200, where face 610 has been rotated and scaled by the face-relatedtransformations discussed above in the context of at least block 1740.Output image 600 also shows that straight lines have been preserved;e.g., straight lines outlining doors, door frames, etc. with respect towall 640 as represented in output image 600 are also shown as straightlines with respect to wall 240 represented in input image 200.

At block 1790, the computing device can provide output image O; e.g.,display part or all of output image O and store part or all of outputimage O in volatile and/or non-volatile memory. Additionally, thecomputing device can communicate part or all of output image O to one ormore other computing devices, print output image O to paper, etc.Further, the computing device can increment/continue timestep t totimestep t+1 and perhaps repeats method 1700 at timestep t+1.

FIG. 18 shows system 1800 illustrating a training phase 1802 and aninference phase 1804 of trained machine learning model(s) 1832, inaccordance with example embodiments. Some machine learning techniquesinvolve training one or more machine learning systems on an input set oftraining data to recognize patterns in the training data and provideoutput inferences and/or predictions about (patterns in the) trainingdata. The resulting trained machine learning system can be called atrained machine learning model or machine learning model, for short. Forexample, FIG. 18 shows training phase 1802 where one or more machinelearning systems 1820 are being trained on training data 1810 to becomeone or more trained machine learning models 1832. Then, during inferencephase 1804, trained machine learning model(s) 1832 can receive inputdata 1830 and one or more inference/prediction requests 1840 (perhaps aspart of input data 1830) and responsively provide as an output one ormore inferences and/or predictions 1850.

Machine learning system(s) 1820 may include, but are not limited to: anartificial neural network, a Bayesian network, a hidden Markov model, aMarkov decision process, a logistic regression function, a supportvector machine, a suitable statistical machine learning algorithm,and/or a heuristic machine learning system. During training phase 1802,machine learning system(s) 1820 can be trained by providing at leasttraining data 1810 as training input using training techniques, such asbut not limited to, unsupervised, supervised, semi-supervised,reinforcement learning, transfer learning, incremental learning, and/orcurriculum learning techniques.

Unsupervised learning involves providing a portion (or all) of trainingdata 1810 to machine learning system(s) 1820. Then, machine learningsystem(s) 1820 can determine one or more output inferences based on theprovided portion (or all) of training data 1810. Supervised learning caninvolve providing a portion of training data 1810 to machine learningsystem(s) 1820, with machine learning system(s) 1820 determining one ormore output inferences based on the provided portion of training data1810, and the output inference(s) are either accepted or corrected basedon correct results associated with training data 1810. In some examples,supervised learning of machine learning system(s) 1820 can be governedby a set of rules and/or a set of labels for the training input, and theset of rules and/or set of labels may be used to correct inferences ofmachine learning system(s) 1820.

Semi-supervised learning can involve having correct results for part,but not all, of training data 1810. During semi-supervised learning,supervised learning is used for a portion of training data 1810 havingcorrect results, and unsupervised learning is used for a portion oftraining data 1810 not having correct results. Reinforcement learninginvolves machine learning system(s) 1820 receiving a reward signalregarding a prior inference, where the reward signal can be a numericalvalue. During reinforcement learning, machine learning system(s) 1820can output an inference and receive a reward signal in response, wheremachine learning system(s) 1820 are configured to try to maximize thenumerical value of the reward signal. In some examples, reinforcementlearning also utilizes a value function that provides a numerical valuerepresenting an expected total of the numerical values provided by thereward signal over time.

Transfer learning techniques can involve trained machine learningmodel(s) 1832 being pre-trained on one set of data and additionallytrained using training data 1810. More particularly, machine learningsystem(s) 1820 can be pre-trained on data from one or more computingdevices and a resulting trained machine learning model provided tocomputing device CD1, where CD1 is intended to execute the trainedmachine learning model during inference phase 1804. Then, duringtraining phase 1802, the pre-trained machine learning model can beadditionally trained using training data 1810, where training data 1810can be derived from kernel and non-kernel data of computing device CD1.This further training of the machine learning system(s) 1820 and/or thepre-trained trained machine learning model using training data 1810 ofCD1's data can be performed using either supervised or unsupervisedlearning. Once machine learning system(s) 1820 and/or the pre-trainedmachine learning model has been trained on at least training data 1810,training phase 1802 can be completed. The trained resulting machinelearning model can be utilized as at least one of trained machinelearning model(s) 1832.

Incremental learning techniques can involve providing trained machinelearning model(s) 1832 (and perhaps machine learning system(s) 1820)with input data that is used to continuously extend knowledge of trainedmachine learning model(s) 1832. Curriculum learning techniques. caninvolve machine learning system(s) 1820 with training data arranged in aparticular order, such as providing relatively-easy training examplesfirst and proceeding with progressively more difficult training examplese.g., analogously to a curriculum or course of study at a school. Othertechniques for training machine learning system(s) 1820 and/or trainedmachine learning model(s) 31832 are possible as well.

In some examples, after training phase 1802 has been completed butbefore inference phase 1804 begins, trained machine learning model(s)1832 can be provided to a computing device CD1 where trained machinelearning model(s) 1832 are not already resident; e.g., after trainingphase 1802 has been completed, trained machine learning model(s) 1832can be downloaded to computing device CD1.

For example, a computing device CD2 storing trained machine learningmodel(s) 1832 can provide trained machine learning model(s) 1832 tocomputing device CD1 by one or more of: communicating a copy of trainedmachine learning model(s) 1832 to computing device CD1, making a copy oftrained machine learning model(s) 1832 for computing device CD1,providing access to trained machine learning model(s) 1832 computingdevice CD1, and/or otherwise providing the trained machine learningsystem to computing device CD1. In some examples, trained machinelearning model(s) 1832 can be used by computing device CD1 immediatelyafter being provided by computing device CD2. In some examples, aftertrained machine learning model(s) 1832 are provided to computing deviceCD1, trained machine learning model(s) 1832 can be installed and/orotherwise prepared for use before trained machine learning model(s) 1832can be used by computing device CD1.

During inference phase 1804, trained machine learning model(s) 1832 canreceive input data 1830 and generate and output correspondinginference(s) and/or prediction(s) 1850 about input data 1830. As such,input data 1830 can be used as an input to trained machine learningmodel(s) 1832 for providing corresponding inference(s) and/orprediction(s) 1850 to kernel components and non-kernel components. Forexample, trained machine learning model(s) 1832 can generateinference(s) and/or prediction(s) 1850 in response toinference/prediction request(s) 1840. In some examples, trained machinelearning model(s) 1832 can be executed by a portion of other software.For example, trained machine learning model(s) 1832 can be executed byan inference or prediction daemon to be readily available to provideinferences and/or predictions upon request. Input data 1830 can includedata from computing device CD1 executing trained machine learningmodel(s) 1832 and/or input data from one or more computing devices otherthan CD1.

In some examples, input data 1830 can include a collection of imagesprovided by one or more sources. The collection of images can includeimages of an object, such as a human face, where the images of the humanface are taken under different lighting conditions, images of multiplehuman faces, images of human bodies, images resident on computing deviceCD1, and/or other images. Other types of input data are possible aswell.

Inference(s) and/or prediction(s) 1850 can include output images,segmentation masks, numerical values, and/or other output data producedby trained machine learning model(s) 1832 operating on input data 1830(and training data 1810). In some examples, trained machine learningmodel(s) 1832 can use output inference(s) and/or prediction(s) 1850 asinput feedback 1860. Trained machine learning model(s) 1832 can alsorely on past inferences as inputs for generating new inferences.

In some examples, machine learning system(s) 1820 and/or trained machinelearning model(s) 1832 can be executed and/or accelerated using one ormore computer processors and/or on-device coprocessors. The on-devicecoprocessor(s) can include, but are not limited to one or more graphicprocessing units (GPUs), one or more tensor processing units (TPUs), oneor more digital signal processors (DSPs), and/or one or more applicationspecific integrated circuits (ASICs). Such on-device coprocessors canspeed up training of machine learning system(s) 1820 and/or generationof inference(s and/or prediction(s) 1850 by trained machine learningmodel(s) 1832. In some examples, trained machine learning model(s) 1832can be trained, reside and execute to provide inference(s) and/orprediction(s) 1850 on a particular computing device, and/or otherwisecan make inferences for the particular computing device.

FIG. 19 is a flowchart of method 1900, in accordance with an exampleembodiment. Method 1900 may represent the procedures of block 1720 ofmethod 1700. For example, the computing device performing method 1700can perform some or all of the procedures of method 1900 whileperforming the procedures of block 1720 of method 1700.

During method 1900, the computing device receives input image 1910,which may correspond to image I_(t) from method 1700. Input image 1910can be provided to neural network 1920, which can responsively generatesegmentation mask 1930 for input image 1910. Neural network 1920 can bean example of machine learning system(s) 1820 of system 1800 discussedabove in the context of FIG. 18. After training, the trained version ofneural network 1920 can be an example of trained machine learningmodel(s) 1832. In this specific example, input data 1830 of system 1800can include input image 1910, inference/prediction request(s) 1840 ofsystem 1800 can include a request for a segmentation mask for inputimage 1910, and inferences and/or prediction(s) 1850 can includesegmentation mask 1930 for input image 1910. Segmentation mask 1930 canbe stored, communicated, and/or otherwise provided. In some embodiments,method 1900 may continue with segmentation mask 1930 and input image1910 being provided to rendering software 1940, which uses segmentationmask 1930 to selectively mask sections of input image 1910; e.g., bymasking background objects and not masking foreground objects.

In some examples, neural network 1920 can receive training images,including images with segmentation data, to produce estimatedsegmentations masks, such as segmentation mask 1930. Neural network 1920can be trained on a relatively-large dataset (e.g., 50,000 or more) oftraining images. The dataset of training images can include imagescontaining a single human face/body, or multiple human faces/body.Moreover, the dataset of training images can include images containinghuman faces/bodies in a variety foreground poses and backgroundsettings. The dataset of training images can be annotated (e.g.,labelled, classified, and/or assigned a ground truth value) withpixel-accurate locations of foreground elements associated with humanfaces/human bodies; e.g., hair, glasses, neck, skin, lips, etc.Background elements not associated with human faces/human bodies canalso be annotated.

In some examples, training images are adjusted to achieve frame-to-frametemporal continuity. More specifically, a given training image may becombined with the segmentation mask from a preceding time step to adjustfor temporal discontinuities that may occur between successive images(e.g., people suddenly appearing in the field of view of the camerabetween timesteps). For example, if neural network 1920 is currentlytraining on training image X, the segmentation mask for training imageX−1 may be included as part of training image X, where training image Xis captured subsequent to training image X−1. Further, segmentationmasks for previous time steps may be annotated in several ways toaccount for different types of scenarios. In some cases, thesegmentation mask for a previous training image may be empty, whichtrains neural network 1920 to work correctly for a first frame in animage sequence and for new objects that appear in an environment (e.g.,the case of someone suddenly appearing in the camera's frame). In othercases, the segmentation mask from a previous training image may undergoan affine transformation, which trains neural network 1920 to use theprevious frame mask to achieve a smooth transition between successiveframes. In further cases, the segmentation mask for a previous trainingimage may undergo a major transformation, which trains neural network1920 to understand inadequate masks (e.g., segmentation masks thatcauses high prediction errors) and discard them. Other annotated/labelsfor segmentations masks are also possible.

In some examples, the training images used to train neural network 1920can contain images not containing any human faces/bodies. In such ascenario, the training images can be classified based on object types;e.g., one or more object types for plants, one or more object types forbuildings, one or more object types for landscapes, one or more objecttypes for animals, one or more object types for persons, including oneor more object types for faces of persons. In some of these examples,the training images can include images with foreground objects havingone or more specified object types; e.g., images of people, images offaces of people, images of buildings, etc.

FIG. 19 also shows image 1960, which depicts a person as foregroundobject 1962 in front of background region 1964. In this example, image1960 is provided to neural network 1920 as an input; e.g., an instanceof input image 1910. Neural network 1920 responsively generatessegmentation mask 1970 for image 1960. In the illustration ofsegmentation mask 1970 in FIG. 19, the lighter-colored pixels in region1972 correspond to portions of image 1960 that represent a humanface/human body and darker-colored pixels in region 1974 correspond toportions of image 1960 that do not represent a human face/human body.

FIG. 20A illustrates neural network 1920 of method 1900, in accordancewith example embodiments. Neural network 1920 can be a convolutionalencoder-decoder neural network. In some examples, part or all of neuralnetwork 1920 can be implemented using specialized hardware and/orsoftware designed for neural networks; e.g., specialized neural networkcircuitry, software libraries with software supporting neural networks.

As indicated above, neural network 1920 can receive input image 1910 andresponsively generate segmentation mask 1930 for input image 1910 as anoutput. In the description of neural network 1920, the dimensions ofvolumes are presented in the form H×W×D, where H is a positive integerassociated with a number of horizontal pixels (or rows of pixels) of thevolume, W is a positive integer associated with a number of verticalpixels (or columns of pixels) of the volume, and D is a positive integerassociated with the number of channels of the volume (e.g., depth).

Generally speaking, the architecture illustrated in FIG. 20A consists ofa contracting/encoding path (e.g., the layers of neural network 1920from layer(s) 2002 to layer(s) 2016) and an expansive/decoding path(e.g., the layers of neural network 1920 from layer(s) 2018 to layer(s)2028).

During operations, neural network 1920 may receive input image 1910 atadder 2000. The input image may be a 192×192×3 volume. As mentionedabove, adder 2000 may operate to add input image 1910 with the output ofneural network 1920 from the previous timestep. In particular,segmentation mask 1930 from the previous timestep may be transformedinto resized mask 2030. The dimensions of resized mask 2030 may matchthose of input image 1910. Adder 2000 can append resized mask 2030 asanother channel for input image 1910 (e.g., converts input image 1910from a 192×192×3 volume into a 192×192×4 volume, with the resized mask2030 being the additional channel). The output of adder 2000 can bepassed to layer(s) 2002.

Layer(s) 2002 perform a 2-D convolution with a 3×3 kernel with stride 3,followed by a batch normalization operation, followed by a parametricrectified linear unit (PReLU) operation on the output from adder 2000 togenerate a 64×64×8 volume as output. Layer(s) 2002 pass the 664×64×8volume as input to layer(s) 2004. Notably, other types of normalizationor activation functions may also be used.

Layer(s) 2004 perform a 2-D convolution with a 2×2 kernel with stride 1,followed by a batch normalization operation, followed by a PReLUoperation on the input from layer(s) 2002 to generate a 64×64×32 volumeas output. Layer(s) 2004 pass the 64×64×32 volume as input to layer(s)2006, which perform encoder bottleneck with down-sampling operations onthe output from layer(s) 2004.

FIG. 20B illustrates encoder bottleneck with down-sampling function 2040that neural network 1920 can use to perform encoder bottleneck withdown-sampling operations, in accordance with example embodiments. Forexample, encoder bottleneck with down-sampling function 2040 can be usedto implement some or all of layer(s) 2006 and layer(s) 2014.

Encoder bottleneck with down-sampling function 2040 can be invoked withan input H×W×D volume. Upon invocation, encoder bottleneck withdown-sampling function 2040 provides the H×W×D volume to layer(s) 2040A.Layer(s) 2040A perform a 2-D convolution on the H×W×D volume with a 2×2kernel, followed by a batch normalization and PReLU operation and passthe output to layer(s) 2040B. Layer(s) 2040B perform a 2-D depthwiseconvolution with a 3×3 kernel and pass the output to layer(s) 2040C.Layer(s) 2040C perform a 2-D convolution with a 1×1 kernel, followed bya batch normalization and PReLU operation and pass the output tolayer(s) 2040D. Layer(s) 2040D perform a 2-D depthwise convolution witha 3×3 kernel and pass the output to layer(s) 2040E. Layer(s) 2040Eperform a batch normalization and PReLU operation and pass the output tolayer(s) 2040F. Layer(s) 2040F perform a 2-D convolution with a 1×1kernel, followed by a batch normalization and a dropout operation andpass the output to layer(s) 20401.

Simultaneously and/or additionally, encoder bottleneck withdown-sampling function 2040 provides the H×W×D volume to layer(s) 2040G.Layer(s) 2040G perform a 2-D depthwise convolution with a 2×2 kernel andpass the output to layer(s) 2040H. Layer(s) 2040H perform a 2-Dconvolution with a 1×1 kernel and pass the output to layer(s) 20401.

Layer(s) 20401 perform an addition on the output from layer(s) 2040F andlayer(s) 2040H and provide the output to layer(s) 2040J. Layer(s) 2040Jperform a PreLU operation to generate an output volume of(H/2)×(W/2)×*(2*D).

Returning to FIG. 20A, the output of layer(s) 2006 may be a 32×32×64volume. Layer(s) 2006 pass the 32×32×64 volume as input to layer(s)2008, which perform encoder bottleneck operations on the output fromlayer(s) 2006.

FIG. 20C illustrates encoder bottleneck function 2050 that neuralnetwork 1920 can use to perform encoder bottleneck operations, inaccordance with example embodiments. For example, encoder bottleneckfunction 2050 can be used to implement some or all of layer(s) 2008 andlayer(s) 2012.

Encoder bottleneck function 2050 can be invoked with an input H×W×Dvolume. Upon invocation, encoder bottleneck function 2050 provides theH×W×D volume to layer(s) 2050A. Layer(s) 2050A perform a 2-D convolutionon the H×W×D volume with a 1×1 kernel, followed by a batch normalizationand PReLU operation and pass the output to layer(s) 2050B. Layer(s)2050B perform a 2-D depthwise convolution with a 3×3 kernel and pass theoutput to layer(s) 2050C. Layer(s) 2050C perform a 2-D convolution witha 1×1 kernel, followed by a batch normalization and PReLU operation andpass the output to layer(s) 2050D. Layer(s) 2050D perform a 2-Ddepthwise convolution with a 3×3 kernel and pass the output to layer(s)2050E. Layer(s) 2050E perform a batch normalization and PReLU operationand pass the output to layer(s) 2050F. Layer(s) 2050F perform a 2-Dconvolution with a 1×1 kernel, followed by a batch normalization and adropout operation and pass the output to layer(s) 2050G.

Simultaneously and/or additionally, encoder bottleneck function 2050provides the original H×W×D volume to layer(s) 2050G.

Layer(s) 2050G perform an addition on the output from layer(s) 2050F andthe original H×W×D volume and provide the output to layer(s) 2050H.Layer(s) 2050H perform a PreLU to generate an output volume of H×W×D.

Returning to FIG. 20A, the output of layer(s) 2008 may be a 32×32×64volume. Layer(s) 2008 pass the 32×32×64 volume as input to layer(s)2010, which perform encoder bottleneck with downsample and maxpooloperations on the output from layer(s) 2008.

FIG. 20D illustrates an encoder bottleneck with down-sampling andmaxpool function 2060 that neural network 1920 can use to performencoder bottleneck with downsample and maxpool operations, in accordancewith example embodiments. For example, encoder bottleneck withdown-sampling and maxpool function 2060 can be used to implement some orall of layer(s) 2010.

Encoder bottleneck with down-sampling and maxpool function 2060 can beinvoked with an input H×W×D volume. Upon invocation, encoder bottleneckwith down-sampling and maxpool function 2060 provides the H×W×D volumeto layer(s) 2060A. Layer(s) 2060A perform a 2-D convolution on the H×W×Dvolume with a 2×2 kernel, followed by a batch normalization and PReLUoperation and pass the output to layer(s) 2060B. Layer(s) 2060B performa 2-D depthwise convolution with a 3×3 kernel and pass the output tolayer(s) 2060C. Layer(s) 2060C perform a 2-D convolution with a 1×1kernel, followed by a batch normalization and PReLU operation and passthe output to layer(s) 2060D. Layer(s) 200D perform a 2-D depthwiseconvolution with a 3×3 kernel and pass the output to layer(s) 2060E.Layer(s) 2060E perform a batch normalization and PReLU operation andpass the output to layer(s) 2060F. Layer(s) 2060F perform a 2-Dconvolution with a 1×1 kernel, followed by a batch normalization and adropout operation and pass the output to layer(s) 2060J.

Simultaneously and/or additionally, encoder bottleneck withdown-sampling and maxpool function 2060 provides the original H×W×Dvolume to layer(s) 2060G. Using maxpool indices 20601, layer(s) 2060Gperform an argmax maxpooling operation with a 2×2 kernel and pass theoutput to layer(s) 2060H. Layer(s) 2060H perform a 2-D convolution witha 1×1 kernel and pass the output to layer(s) 2060J.

Layer(s) 2060J perform an addition on the output from layer(s) 2060F andlayer(s) 2060H and provide the output to layer(s) 2060K. Layer(s) 2060Kperform a PreLU to generate an output volume of (H/2)×(W/2)×(2*D).

Returning to FIG. 20A, the output of layer(s) 2010 may be a 16×16×128volume. Layer(s) 2010 pass the 16×16×128 volume as input to layer(s)2012, which perform encoder bottleneck operations on the output fromlayer(s) 2010, as previously described with respect to FIG. 20C. Theoutput of layer(s) 2012 may be a 16×16×128 volume. Layer(s) 2010 mayalso pass the 16×16×128 volume as input to layers(s) 2020 and may passmax-pooling indices to layer(s) 2024 (e.g., a skip connection).

Layer(s) 2012 pass the 16×16×128 volume as input to layer(s) 2014, whichperform encoder bottleneck with down-sampling operations on the outputfrom layer(s) 2012, as previously described with respect to FIG. 20B.The output of layer(s) 2014 may be an 8×8×128 volume.

Layer(s) 2014 pass the 8×8×128 volume as input to layer(s) 2016, whichperform encoder bottleneck operations on the output from layer(s) 2014,as previously described with respect to FIG. 20C. The output of layer(s)2016 may be an 8×8×128 volume.

Layer(s) 2016 pass the 8×8×128 volume as input to layer(s) 2018, whichperform decoder bottleneck with up-sampling operations on the outputfrom layer(s) 2016.

FIG. 20D illustrates decoder bottleneck with up-sampling function 2070that neural network 1920 can use to perform decoder bottleneck withup-sampling operations, in accordance with example embodiments. Forexample, decoder bottleneck with up-sampling function 2070 can be usedto implement some or all of layer(s) 2018.

Decoder bottleneck with up-sampling function 2070 can be invoked with aninput H×W×D volume. Upon invocation, decoder bottleneck with up-samplingfunction 2070 provides the H×W×D volume to layer(s) 2070A. Layer(s)2070A perform a 2-D convolution on the H×W×D volume with a 1×1 kernel,followed by a batch normalization and PReLU operation and pass theoutput to layer(s) 2070B. Layer(s) 2070B perform a 2-D transposeconvolution with a 3×3 kernel, followed by a batch normalization andPReLU operation and pass the output to layer(s) 2070C. Layer(s) 2070Cperform a 2-D convolution with a 1×1 kernel, followed by a batchnormalization and PReLU operation and pass the output to layer(s) 2070F.

Simultaneously and/or additionally, decoder bottleneck with up-samplingfunction 2070 provides the original H×W×D volume to layer(s) 2070D.Layer(s) 2070D perform a 2-D convolution on the H×W×D volume with a 1×1kernel, followed by a batch normalization and PReLU operation and passthe output to layer(s) 2070E. Using maxpool indices 2070G (for examplepassed from layer(s) 2010), layer(s) 2070G perform an 2-D max-unpoolingoperation and pass the output to layer(s) 2070F.

Layer(s) 20701 perform an addition on the output from layer(s) 2070G andlayer(s) 2070C and provide the output to layer(s) 20701. Layer(s) 20701perform a PreLU to generate an output volume of (H*2)×(W*2)×D.

Returning to FIG. 20A, the output of layer(s) 2018 may be a 16×16×128volume. Layer(s) 2018 pass the 16×16×128 volume as input to layer(s)2020, which may concatenate the output from layer(s) 2018 with theoutput from layer(s) 2010. The output of layer(s) 2020 may be a16×16×256 volume. Layer(s) 2020 pass the 16×16×256 volume as input tolayer(s) 2022, which perform decoder bottleneck operations on the outputfrom layer(s) 2022.

FIG. 20F illustrates decoder bottleneck function 2080 that neuralnetwork 1920 can use to perform decoder bottleneck operations, inaccordance with example embodiments. For example, decoder bottleneckfunction 2080 can be used to implement some or all of layer(s) 2022 andlayer(s) 2026.

Decoder bottleneck function 2080 can be invoked with an input H×W×Dvolume. Upon invocation, decoder bottleneck function 2080 provides theH×W×D volume to layer(s) 2080A. Layer(s) 2080A perform a 2-D convolutionon the H×W×D volume with a 1×1 kernel, followed by a batch normalizationand PReLU operation and pass the output to layer(s) 2080B. Layer(s)2080B perform a 2-D convolution with a 3×3 kernel with stride 1,followed by a batch normalization and PReLU operation and pass theoutput to layer(s) 2080C. Layer(s) 2080C perform a 2-D convolution witha 1×1 kernel, followed by a batch normalization and PReLU operation andpass the output to layer(s) 2080E.

Simultaneously and/or additionally, decoder bottleneck function 2080provides the input H×W×D volume to layer(s) 2080D. Layer(s) 2080Dperform a 2-D convolution with a 1×1 kernel, followed by a batchnormalization and PReLU operation and pass the output to layer(s) 2080E.

Layer(s) 2080E perform an addition on the output from layer(s) 2080C andlayer(s) 2080D and provide the output to layer(s) 2080F. Layer(s) 2080Fperform a PreLU to generate an output volume of H×W×(D/2).

Returning to FIG. 20A, the output of layer(s) 2022 may be a 16×16×128volume. Layer(s) 2022 pass the 16×16×128 volume as input to layer(s)2024, which may perform decoder bottleneck with max-unpool operations onthe output from layer(s) 2022.

FIG. 20G illustrates decoder bottleneck with max-unpool function 2090that neural network 1920 can use to perform decoder bottleneck withmax-unpool operations, in accordance with example embodiments. Forexample, decoder bottleneck function 2080 can be used to implement someor all of layer(s) 2024.

Decoder bottleneck with max-unpool function 2090 can be invoked with aninput H×W×D volume. Upon invocation, decoder bottleneck with max-unpoolfunction 2090 provides the H×W×D volume to layer(s) 2090A. Layer(s)2090A perform a 2-D convolution on the H×W×D volume with a 1×1 kernel,followed by a batch normalization and PReLU operation and pass theoutput to layer(s) 2090B. Layer(s) 2090B perform a 2-D convolution witha 3×3 kernel, stride 1, followed by a batch normalization and PReLUoperation and pass the output to layer(s) 2090C. Layer(s) 2090C performa 2-D convolution with a 1×1 kernel, followed by a batch normalizationand PReLU operation and pass the output to layer(s) 2090G.

Simultaneously and/or additionally, decoder bottleneck with max-unpoolfunction 2090 provides the input H×W×D volume to layer(s) 2090D.Layer(s) 2090D perform a 2-D convolution with a 1×1 kernel, followed bya batch normalization and PReLU operation and pass the output tolayer(s) 2090E. Using maxpool indices 2090F received from layer(s) 2010,layer(s) 2090E perform a maxpooling operation with a 2×2 kernel and passthe output to layer(s) 2090G.

Layer(s) 2080G perform an addition on the output from layer(s) 2090E andlayer(s) 2090C and provide the output to layer(s) 2090H. Layer(s) 2090Hperform a PreLU to generate an output volume of (2*H)×(2*W)×(D/2).

Returning to FIG. 20A, the output of layer(s) 2024 may be a 32×32×64volume. Layer(s) 2024 pass the 32×32×64 volume as input to layer(s)2026, which perform decoder bottleneck operations on the output fromlayer(s) 2024, as previously described with respect to FIG. 20F. Theoutput of layer(s) 2026 may be a 32×32×32 volume. Layer(s) 2026 pass the32×32×32 volume as input to layer(s) 2028, which perform a 2-Dconvolutional transpose operation with a 2×2 kernel with stride 1 on theoutput from layer(s) 2026.

The output of layer(s) 2028 may be a 32×32×2 volume and may correspondto segmentation mask 1920 from FIG. 19.

It should be noted that the layers illustrated in neural network 1920are a convenient conceptual representation of an architecture, but arenot intended to be limiting with respect to example embodiments ortechniques described herein. In further examples, neural network 1920can have more or less layers with different functions.

FIG. 21 is a flowchart of a method for the procedures of block 1740 ofmethod 1700, in accordance with an example embodiment. For example, thecomputing device performing method 1700 can perform some or all of theprocedures of blocks 2110, 2120, 2130, 2140, 2150, 2160, and 2170 whileperforming the procedures of block 1740 of method 1700.

At block 2110, the computing device can perform, on image I_(t), theprocedures of blocks 900, 910, 920, 930, 940, 950, 960, and 970 aspreviously described with respect to FIG. 9.

At block 2120, the computing device can determine whether N_(t) (e.g.,the number of faces represented in image I_(t)) equals N_(t-1) (e.g.,the number of faces represented in image I_(t-1)). Both N_(t) andN_(t-1) can be calculated using the procedures of block 1720 of method1700 and the computing device may store the results of N_(t) and N_(t-1)for later use. If the computing device determines that N_(t) equalsN_(t-1), then the computing device can proceed to block 2140. Otherwise,the computing device can determine that N_(t) does not equal N_(t-1) andcan proceed to block 2130.

At block 2130, the computing device can set the value of weight termW_(t) to be N_(t)−N_(t-1)*W_(t-1), where W_(t-1) is the weight term ofthe previous image I_(t-1). The idea here is that if N_(t) does notequal N_(t-1) (e.g., the number of faces has changed from one image tothe next image), then W_(t) should increase from the previous timestept−1 so as to keep mesh v at timestep t similar to mesh v at timestept−1.

At block 2140, the computing device can set the value of weight termW_(t) to be W_(t-1)−M, where W_(t-1) is the weight term of the previousimage I_(t-1) and where M is a predefined number (e.g., M=0.01, 1, 2,10, 1000). The reasoning here is that if N_(t) equals N_(t-1) (e.g., thenumber of faces has not changed from one image to the next image), thenW_(t) should decrease from the previous timestep t−1 so as to allow meshv at timestep t to deviate from mesh v at timestep t−1.

At block 2150, the computing device can associate each vertex in mesh vwith temporal coherence term TCCT_(t). In examples, the temporalcoherence term is computed as TCCT_(t)=W_(t)*|v_(t)−v_(t-1)|², whereW_(t) is the weighting term set in blocks 2130 or block 2140, v_(t) arethe vertices of mesh v at timestep t, and v_(t-1) are the vertices ofmesh v at timestep t−1 (e.g., the mesh from the previous timestep). Theidea behind the temporal coherence term is to balance deviations of meshv between timestep t and timestep t−1. For example, if W_(t) is set to ahigh value, then large deviations in mesh v between timestep t andtimestep t−1 (e.g., v_(t)−v_(t-1)) carry a high cost and may nottranspire during the optimization process. But if W_(t) is set to a lowvalue, then large deviations in mesh v do not carry a high cost and maytranspire during the optimization process.

At block 2160, the computing device can associate each vertex in mesh vwith mesh prediction cost term MPCT_(t). In examples, the meshprediction cost term is computed as MPCT_(t)=|v_(t)−p(v_(t-1),v_(t-2))|², where v_(t) are the vertices of mesh v at timestep t,v_(t-1) are the vertices of mesh v at timestep t−1, v_(t-2) are thevertices of mesh v at timestep t−2, and where p(v_(t-1), v_(t-2)) is alinear prediction 2*v_(t-1)−v_(t-2). The idea behind the mesh predictioncost term is to ensure mesh v undergoes sufficient change betweentimestep t and timestep t−1. In particular, the linear prediction2*v_(t-1)−v_(t-2) places a high cost on small deviations in mesh vbetween timestep t and timestep t−1. For example, if v_(t)=v_(t-1), thenMPCT_(t) carries a high cost. But if v_(t)=2*v_(t-1), then MPCT_(t) doesnot carry a high cost.

At block 2170, the computing device can proceed with the remainder ofmethod 1700; i.e., complete the procedures of block 1740 of method 1700and continue method 1700 by beginning performance of the procedures ofblock 1750 of method 1700.

Example Data Network

FIG. 22 depicts a distributed computing architecture 2200, in accordancewith an example embodiment. Distributed computing architecture 2200 caninclude server devices 2208, 2210 configured to communicate, via network2206, with programmable devices 2204 a, 2204 b, 2204 c, 2204 d, 2204 e.Network 2206 may correspond to a LAN, a wide area network (WAN), acorporate intranet, the public Internet, or any other type of networkconfigured to provide a communications path between networked computingdevices. Network 2206 may also correspond to a combination of one ormore LANs, WANs, corporate intranets, and/or the public Internet.

Although FIG. 22 only shows five programmable devices, distributedapplication architectures may serve tens, hundreds, or thousands ofprogrammable devices. Moreover, programmable devices 2204 a, 2204 b,2204 c, 2204 d, 2204 e, (or any additional programmable devices) may beany sort of computing device, such as an ordinary laptop computer,desktop computer, wearable computing device, mobile computing device,head-mountable device, network terminal, wireless communication device(e.g., a smart phone or cell phone), and so on. In some embodiments,such as indicated with programmable devices 2204 a, 2204 b, 2204 c,programmable devices can be directly connected to network 2206. In otherembodiments, such as indicated with programmable device 2204 d,programmable devices can be indirectly connected to network 2206 via anassociated computing device, such as programmable device 2204 c. In thisexample, programmable device 2204 c can act as an associated computingdevice to pass electronic communications between programmable device2204 d and network 2206. In yet other embodiments, such as shown inprogrammable device 2204 e, a computing device can be part of and/orinside a vehicle; e.g., a car, a truck, a bus, a boat or ship, anairplane, etc. In still other embodiments not shown in FIG. 22, aprogrammable device can be both directly and indirectly connected tonetwork 2206.

Server devices 2208, 2210 can be configured to perform one or moreservices, as requested by programmable devices 2204 a-2204 e. Forexample, server device 2208 and/or 2210 can provide content toprogrammable devices 2204 a-2204 e. The content can include, but is notlimited to, web pages, hypertext, scripts, binary data such as compiledsoftware, images, audio, and/or video. The content can includecompressed and/or uncompressed content. The content can be encryptedand/or unencrypted. Other types of content are possible as well.

As another example, server device 2208 and/or 2210 can provideprogrammable devices 2204 a-2204 e with access to software for database,search, computation, graphical, audio, video, World Wide Web/Internetutilization, and/or other functions. Many other examples of serverdevices are possible as well.

Computing Device Architecture

FIG. 23 is a functional block diagram of an example computing device2300, in accordance with an example embodiment. In particular, computingdevice 2300 shown in FIG. 23 can be configured to perform at least onefunction of input image 200, image mask 300, warping mesh 400, optimizedmesh 500, output image 600, computing device 1610, machine learningsystem 1800, neural network 1920, distributed computing architecture2200, programmable devices 2204 a, 2204 b, 2204 c, 2204 d, 2204 e,network 2206, and/or server devices 2208, 2210, and/or at least onefunction related to method 100, scenario 1400, scenario 1500, scenario1600, method 1700, method 1900, and/or method 2400.

Computing device 2300 may include user interface module 2301, networkcommunications interface module 2302, one or more processors 2303, datastorage 2304, and one or more sensors 2320, all of which may be linkedtogether via a system bus, network, or other connection mechanism 2305.

User interface module 2301 can be operable to send data to and/orreceive data from external user input/output devices. For example, userinterface module 2301 can be configured to send and/or receive data toand/or from user input devices such as a touch screen, a computer mouse,a keyboard, a keypad, a touch pad, a track ball, a joystick, a camera, avoice recognition module, and/or other similar devices. User interfacemodule 2301 can also be configured to provide output to user displaydevices, such as one or more cathode ray tubes (CRT), liquid crystaldisplays, light emitting diodes (LEDs), displays using digital lightprocessing (DLP) technology, printers, light bulbs, and/or other similardevices, either now known or later developed. User interface module 2301can also be configured to generate audible outputs, such as a speaker,speaker jack, audio output port, audio output device, earphones, and/orother similar devices. User interface module 2301 can further beconfigured with one or more haptic devices that can generate hapticoutputs, such as vibrations and/or other outputs detectable by touchand/or physical contact with computing device 2300. In some embodiments,user interface module 2301 can be used to provide a graphical userinterface for utilizing computing device 2300.

Network communications interface module 2302 can include one or morewireless interfaces 2307 and/or one or more wireline interfaces 2308that are configurable to communicate via a network. Wireless interfaces2307 can include one or more wireless transmitters, receivers, and/ortransceivers, such as a Bluetooth™ transceiver, a Zigbee® transceiver, aWi-Fi™ transceiver, a WiMAX™ transceiver, and/or other similar type ofwireless transceiver configurable to communicate via a wireless network.Wireline interfaces 2308 can include one or more wireline transmitters,receivers, and/or transceivers, such as an Ethernet transceiver, aUniversal Serial Bus (USB) transceiver, or similar transceiverconfigurable to communicate via a twisted pair wire, a coaxial cable, afiber-optic link, or a similar physical connection to a wirelinenetwork.

In some embodiments, network communications interface module 2302 can beconfigured to provide reliable, secured, and/or authenticatedcommunications. For each communication described herein, information forensuring reliable communications (i.e., guaranteed message delivery) canbe provided, perhaps as part of a message header and/or footer (e.g.,packet/message sequencing information, encapsulation headers and/orfooters, size/time information, and transmission verificationinformation such as cyclic redundancy check (CRC) and/or parity checkvalues). Communications can be made secure (e.g., be encoded orencrypted) and/or decrypted/decoded using one or more cryptographicprotocols and/or algorithms, such as, but not limited to, DataEncryption Standard (DES), Advanced Encryption Standard (AES), anRivest-Shamir-Adelman (RSA) algorithm, a Diffie-Hellman algorithm, asecure sockets protocol such as Secure Sockets Layer (SSL) or TransportLayer Security (TLS), and/or Digital Signature Algorithm (DSA). Othercryptographic protocols and/or algorithms can be used as well or inaddition to those listed herein to secure (and then decrypt/decode)communications.

One or more processors 2303 can include one or more general purposeprocessors, and/or one or more special purpose processors (e.g., digitalsignal processors, graphics processing units, application specificintegrated circuits, etc.). One or more processors 2303 can beconfigured to execute computer-readable program instructions 2306 thatare contained in data storage 2304 and/or other instructions asdescribed herein.

Data storage 2304 can include one or more computer-readable storagemedia that can be read and/or accessed by at least one of one or moreprocessors 2303. The one or more computer-readable storage media caninclude volatile and/or non-volatile storage components, such asoptical, magnetic, organic or other memory or disc storage, which can beintegrated in whole or in part with at least one of one or moreprocessors 2303. In some embodiments, data storage 2304 can beimplemented using a single physical device (e.g., one optical, magnetic,organic or other memory or disc storage unit), while in otherembodiments, data storage 2304 can be implemented using two or morephysical devices.

Data storage 2304 can include computer-readable program instructions2306 and perhaps additional data. In some embodiments, data storage 2304can additionally include storage required to perform at least part ofthe herein-described methods, scenarios, and techniques and/or at leastpart of the functionality of the herein-described devices and networks.

In some embodiments, computing device 2300 can include one or moresensors 2320. Sensors 2320 can be configured to measure conditions in anenvironment of computing device 2300 and provide data about thatenvironment. For example, sensors 1820 can include one or more of: (i)an identification sensor to identify other objects and/or devices, suchas, but not limited to, a Radio Frequency Identification (RFID) reader,proximity sensor, one-dimensional barcode reader, two-dimensionalbarcode (e.g., Quick Response (QR) code) reader, and a laser tracker,where the identification sensors can be configured to read identifiers,such as RFID tags, barcodes, QR codes, and/or other devices and/orobject configured to be read and provide at least identifyinginformation; (ii) sensors to measure locations and/or movements ofcomputing device 2300, such as, but not limited to, a tilt sensor, agyroscope, an accelerometer, a Doppler sensor, a Global PositioningSystem (GPS) device, a sonar sensor, a radar device, alaser-displacement sensor, and a compass; (iii) an environmental sensorto obtain data indicative of an environment of computing device 2300,such as, but not limited to, an infrared sensor, an optical sensor, alight sensor, a camera, a biosensor, a capacitive sensor, a touchsensor, a temperature sensor, a wireless sensor, a radio sensor, amovement sensor, a microphone, a sound sensor, an ultrasound sensor,and/or a smoke sensor; and (iv) a force sensor to measure one or moreforces (e.g., inertial forces and/or G-forces) acting about computingdevice 2300, such as, but not limited to one or more sensors thatmeasure: forces in one or more dimensions, torque, ground force,friction, and/or a zero moment point (ZMP) sensor that identifies ZMPsand/or locations of the ZMPs. Many other examples of sensors 2320 arepossible as well.

Example Methods of Operation

FIG. 24 is a flowchart of a method 2400, in accordance with an exampleembodiment. Method 2400 can be a computer-implemented method. Forexample, method 2400 can be executed by a computing device, such ascomputing device 2300.

FIG. 24 shows that method 2400 can begin at block 2410. At block 2410,the computing device can determine a first image area in an image, suchas discussed above at least in the context of FIGS. 1, 2, 7, 8, 14, 15,16, 17, 19, and 20A.

At block 2420, the computing device can determine a warping mesh for theimage, such as discussed above at least in the context of FIGS. 1, 4, 9,17, and 21.

At block 2430, the computing device can determine a first portion of thewarping mesh, where the first portion of the warping mesh is associatedwith the first image area, such as discussed above at least in thecontext of FIGS. 1, 5, 9, 17, and 21.

At block 2440, the computing device can determine a cost function forthe warping mesh by determining first costs associated with the firstportion of the warping mesh, where the first costs include costsassociated with one or more face-related transformations to correct oneor more geometric distortions in the first image area, such as discussedabove at least in the context of FIGS. 1, 9, 10, 17, and 21.

At block 2450, the computing device can determine an optimized meshbased on an optimization of the cost function for the warping mesh, suchas discussed above at least in the context of FIGS. 1, 5, 10, 11, 17,and 21.

At block 2460, the computing device can modify the first image area inthe image based on the optimized mesh, such as discussed above at leastin the context of FIGS. 1, 6, 12, 13, 14, 15, 16, 17 and 21.

In some examples, the optimization of the cost function can includes aminimization of the cost function; then, determining the optimized meshbased on the optimization of the cost function can include: determiningthe optimized mesh by performing the minimization of the cost functionapplied to the warping mesh, determining a left-maximum cost as amaximum of costs of vertices of a left border of the optimized mesh;determining a right-minimum cost of a minimum of costs of vertices of aright border of the optimized mesh; determining a top-maximum cost as amaximum of costs of vertices of a top border of the optimized mesh;determining a bottom-minimum cost of a minimum of costs of vertices of abottom border of the optimized mesh; and modifying the optimized meshbased on the left-maximum cost, the right-minimum cost, the top-maximumcost, and the bottom-minimum cost, such as discussed above at least inthe context of FIGS. 10, 11, 17 and 21.

In some of these examples, modifying the optimized mesh based on theleft-maximum cost, the right-minimum cost, the top-maximum cost, and thebottom-minimum cost can include: determining a width scale for the imagebased on a width of the image and a difference between the right-minimumcost and the left-maximum cost; determining a height scale for the imagebased on a height of the image and a difference between thebottom-minimum cost and the top-maximum cost; and performing amathematical scaling of the optimized mesh based on the width scale andthe height scale, such as discussed above at least in the context ofFIGS. 11, 17, and 21.

In some examples, the image can include a plurality of pixels; then,modifying the first image area of the image based on the optimized meshcan include: determining a sampled mesh by sampling the optimized mesh,the sampled mesh including a plurality of sampled vertices; for aparticular pixel of the plurality of pixels, modifying the particularpixel by at least: determining one or more neighboring vertices of theplurality of sampled vertices that neighbor the particular pixel;determining coordinates for a resampled pixel of the plurality of pixelsbased on the one or more neighboring vertices; determining pixel valuesfor the resampled pixel by sampling one or more pixels of the pluralityof pixels based on the coordinates for the resampled pixel; andmodifying the particular pixel based on the pixel values for theresampled pixel such as discussed above at least in the context of FIGS.1, 13, 17, and 21.

In other examples, the one or more face-related transformations of atleast the first image area can include a rotation of the first imagearea, a translation of the first image area, and/or a scaling of thefirst image area; then, determining the warping mesh for the image caninclude: determining a third mesh for the image, the third meshincluding a third plurality of vertices; and determining the warpingmesh based on the third mesh by at least: determining one or more sidesof the third mesh, and for each side of the one or more sides of thethird mesh: adding a pre-determined number of additional vertices to theside of the third mesh, after adding the pre-determined number ofadditional vertices to the side of the third mesh, determining aboundary of the third mesh that is associated with the side of the thirdmesh, the boundary associated with boundary vertices of the third mesh,and determining a dimension of the boundary vertices of the third meshto be perpendicular to a boundary of the image, such as discussed aboveat least in the context of FIGS. 1, 9, 10, 17, and 21.

In some examples, determining the first costs associated with the firstportion of the warping mesh can include: mapping the first image area toa first space using a first transformation; mapping the first image areato a second space using a second transformation; determining a firstaspect ratio for the first image area, the first aspect ratio based on aratio of an area of the first space to an area of the second space; anddetermining the first costs associated with the first portion of thewarping mesh based on the first aspect ratio, such as discussed above atleast in the context of FIGS. 9, 17, and 21. In some of these examples,the first transformation can include a perspective transformation, andwhere the second transformation can include a stereographictransformation, such as discussed above at least in the context of FIG.9. In other of these examples, the warping mesh can include a pluralityof vertices; then, determining the first costs associated with the firstportion of the warping mesh can include: initializing a first cost of afirst vertex in the first portion of the warping mesh to a valueassociated with an interpolation of a first-transformation valueassociated with the first transformation at the first vertex and asecond transformation value associated with the first transformation atthe first vertex, such as discussed above at least in the context ofFIGS. 11, 17, and 21.

In some examples, the warping mesh includes a plurality of vertices, anddetermining the cost function includes determining second costsassociated with the warping mesh, where the second costs includes costsof one or more edge-related transformations for preserving straightnessof edges of the image modified at least by the one or more face-relatedtransformations; and where determining the second costs associated withthe warping mesh can include: assigning a per-vertex edge cost for eachvertex of the warping mesh associated with an edge of the image; andassigning a boundary cost for each vertex of the warping mesh associatedwith a boundary of the warping mesh, such as discussed above at least inthe context of FIGS. 10, 17, and 21.

In some examples, assigning the per-vertex edge cost for each vertex ofthe warping mesh associated with an edge of the image can include:determining a first edge-regularization term for a first edge of theimage, where the first edge of the image is associated with at least afirst edge vertex of the warping mesh; determining a first edge-bendingterm for the first edge of the image; and determining the per-vertexedge cost for the first edge vertex based on the firstedge-regularization term and the first edge-bending term, such asdiscussed above at least in the context of FIGS. 10, 17, and 21.

In some examples, assigning the boundary cost for each vertex of thewarping mesh associated with a boundary of the warping mesh can include:determining a boundary-cost value for a first boundary vertex of thewarping mesh, the first boundary vertex associated with a first boundaryof the warping mesh, where the boundary-cost value is based on adistance between the first boundary vertex and a border of the warpingmesh, such as discussed above at least in the context of FIGS. 10, 17,and 21.

In some examples, method 1900 can further include: determining a secondimage area in the image, the second image area differing from the firstimage area; and determining a second portion of the warping mesh, wherethe second portion of the warping mesh is associated with the secondimage area, where determining the cost function for the warping meshfurther includes determining additional first costs associated with thesecond portion of the warping mesh, where the additional first costscomprise costs associated with one or more face-related transformationsto correct one or more geometric distortions in the second image area,such as discussed above at least in the context of FIGS. 1, 7, 14, 15,16, 17, and 21.

In some examples, determining the first image area in the image caninclude applying a neural network on the image to determine asegmentation mask, where the neural network is trained to determine asegmentation mask for a given input image, and providing thesegmentation mask as the first image area, such as discussed above atleast in the context of FIGS. 17, 18, 19, and 20A.

In some examples, the image is part of a set of successive images, andapplying the neural network on the image includes adding, to the image,a prior segmentation mask from a previous image in the set of successiveimages, such as discussed above at least in the context of FIGS. 17, 18,19, and 20A.

In some examples, adding the prior segmentation mask includes resizingan output of the neural network for the previous image to match one ormore dimensions of the image, such as discussed above at least in thecontext of FIGS. 17, 18, 19, and 20A.

In some examples, the image is part of a set of successive images andthe warping mesh is initialized to an optimized mesh of a previous imagein the set of successive images, such as discussed above at least in thecontext of FIGS. 17, 18, 19, and 20A.

In some examples, modifying the first image area of the image based onthe optimized mesh can include: calculating a sampling of the optimizedmesh; and modifying at least the first image area of the image based onthe sampling of the optimized mesh, such as discussed above at least inthe context of FIGS. 1, 12, 13, 17, and 21.

In some examples, the image is part of a set of successive images, thewarping mesh includes a plurality of vertices, and where determining thefirst costs associated with the first portion of the warping meshincludes determining a coherence cost by comparing vertices of thewarping mesh to the vertices of a prior warping mesh from a previousimage in the set of successive images and determining the coherence costbased on the comparison, such as discussed above at least in the contextof FIGS. 17, and 21.

In some examples, determining the coherence cost further includesmathematically scaling the comparison by applying a weighting parameter,where the weighting parameter is associated with a number of regions ofinterests in the image, such as discussed above at least in the contextof FIGS. 17, and 21.

In some examples, the weighting parameter is increased if the number ofregions of interests has changed from the previous image, and theweighting parameter is decreased if the number of regions of interestshas not changed from the previous image, such as discussed above atleast in the context of FIGS. 17, and 21.

In some examples, the image is part of a set of successive images, thewarping mesh comprises a plurality of vertices, and where determiningthe first costs associated with the first portion of the warping meshcomprises determining a prediction cost by: comparing vertices of thewarping mesh to the vertices of a prior warping mesh from a previousimage in the set of successive images, comparing vertices of the warpingmesh to the vertices of a second prior warping mesh from a secondprevious image in the set of successive images, and determining theprediction cost based on the comparisons, such as discussed above atleast in the context of FIGS. 17, and 21.

In some examples, determining the first image area can include obtainingthe image from a camera, such as discussed above at least in the contextof FIGS. 14, 15, and 16.

In some examples, a computing device can be provided, where thecomputing device includes: one or more processors; and one or morecomputer readable media. The one or more computer readable media canhave computer-readable instructions stored thereon that, when executedby the one or more processors, cause the computing device to carry outfunctions that include method 2400.

In other examples, a computing device can be provided, where thecomputing device includes means for carrying out method 2400.

In even other examples, an article of manufacture can be provided. Thearticle of manufacture can include one or more computer readable mediahaving computer-readable instructions stored thereon that, when executedby one or more processors of a computing device, cause the computingdevice to carry out functions that include method 1900. In some of theseexamples, the one or more computer readable media can include one ormore non-transitory computer readable media.

The above detailed description describes various features and functionsof the disclosed systems, devices, and methods with reference to theaccompanying figures. In the figures, similar symbols typically identifysimilar components, unless context dictates otherwise. The illustrativeembodiments described in the detailed description, figures, and claimsare not meant to be limiting. Other embodiments can be utilized, andother changes can be made, without departing from the spirit or scope ofthe subject matter presented herein. It will be readily understood thatthe aspects of the present disclosure, as generally described herein,and illustrated in the figures, can be arranged, substituted, combined,separated, and designed in a wide variety of different configurations,all of which are explicitly contemplated herein.

With respect to any or all of the ladder diagrams, scenarios, and flowcharts in the figures and as discussed herein, each block and/orcommunication may represent a processing of information and/or atransmission of information in accordance with example embodiments.Alternative embodiments are included within the scope of these exampleembodiments. In these alternative embodiments, for example, functionsdescribed as blocks, transmissions, communications, requests, responses,and/or messages may be executed out of order from that shown ordiscussed, including substantially concurrent or in reverse order,depending on the functionality involved. Further, more or fewer blocksand/or functions may be used with any of the ladder diagrams, scenarios,and flow charts discussed herein, and these ladder diagrams, scenarios,and flow charts may be combined with one another, in part or in whole.

A block that represents a processing of information may correspond tocircuitry that can be configured to perform the specific logicalfunctions of a herein-described method or technique. Alternatively oradditionally, a block that represents a processing of information maycorrespond to a module, a segment, or a portion of program code(including related data). The program code may include one or moreinstructions executable by a processor for implementing specific logicalfunctions or actions in the method or technique. The program code and/orrelated data may be stored on any type of computer readable medium suchas a storage device including a disk or hard drive or other storagemedium.

The computer readable medium may also include non-transitory computerreadable media such as non-transitory computer-readable media thatstores data for short periods of time like register memory, processorcache, and random access memory (RAM). The computer readable media mayalso include non-transitory computer readable media that stores programcode and/or data for longer periods of time, such as secondary orpersistent long term storage, like read only memory (ROM), optical ormagnetic disks, compact-disc read only memory (CD-ROM), for example. Thecomputer readable media may also be any other volatile or non-volatilestorage systems. A computer readable medium may be considered a computerreadable storage medium, for example, or a tangible storage device.

Moreover, a block that represents one or more information transmissionsmay correspond to information transmissions between software and/orhardware modules in the same physical device. However, other informationtransmissions may be between software modules and/or hardware modules indifferent physical devices.

Variations of the above referenced approach will be apparent to theskilled person. For example, while the above description providesparticular disclosure of corrections to distortion of faces in an image,the approach may also be applied to other regions or objects ofinterest. As such, where the adjective “facial” is referred to in theabove disclosure (such as in the phrases “facial regions” or “facialtransformation”), the skilled person will appreciate that alternativeapproaches may be adopted in which such an adjective is not required.Similarly, references to “face-related costs”, “face-relatedtransformations” or other “face-related” features may be more generallyconsidered as “object-related” or “region-related” in alternativeimplementations.

While various aspects and embodiments have been disclosed herein, otheraspects and embodiments will be apparent to those skilled in the art.The various aspects and embodiments disclosed herein are provided forexplanatory purposes and are not intended to be limiting, with the truescope being indicated by the following claims.

What is claimed is:
 1. A computer-implemented method, comprising:determining a first image area in an image; determining a warping meshfor the image; determining a first portion of the warping mesh, whereinthe first portion of the warping mesh is associated with the first imagearea; determining a cost function for the warping mesh by determiningfirst costs associated with the first portion of the warping mesh,wherein the first costs comprise costs associated with one or moreface-related transformations to correct one or more geometricdistortions in the first image area; determining an optimized mesh basedon an optimization of the cost function for the warping mesh; andmodifying the first image area in the image based on the optimized mesh.2. The computer-implemented method of claim 1, further comprising:determining a second image area in the image, the second image areadiffering from the first image area; and determining a second portion ofthe warping mesh, wherein the second portion of the warping mesh isassociated with the second image area, wherein determining the costfunction for the warping mesh further comprises determining additionalfirst costs associated with the second portion of the warping mesh, andwherein the additional first costs comprise costs associated with one ormore face-related transformations to correct one or more geometricdistortions in the second image area.
 3. The computer-implemented methodof claim 1, wherein the warping mesh comprises a plurality of vertices,wherein determining the cost function comprises determining second costsassociated with the warping mesh, wherein the second costs comprisecosts of one or more edge-related transformations for preservingstraightness of edges of the image modified at least by the one or moreface-related transformations; and wherein determining the second costsassociated with the warping mesh comprises: assigning a per-vertex edgecost for each vertex of the warping mesh associated with an edge of theimage; and assigning a boundary cost for each vertex of the warping meshassociated with a boundary of the warping mesh.
 4. Thecomputer-implemented method of claim 3, wherein assigning the per-vertexedge cost for each vertex of the warping mesh associated with an edge ofthe image comprises: determining a first edge-regularization term for afirst edge of the image, wherein the first edge of the image isassociated with at least a first edge vertex of the warping mesh;determining a first edge-bending term for the first edge of the image;and determining the per-vertex edge cost for the first edge vertex basedon the first edge-regularization term and the first edge-bending term.5. The computer-implemented method of claim 3, wherein assigning theboundary cost for each vertex of the warping mesh associated with aboundary of the warping mesh comprises: determining a boundary-costvalue for a first boundary vertex of the warping mesh, the firstboundary vertex associated with a first boundary of the warping mesh,wherein the boundary-cost value is based on a distance between the firstboundary vertex and a border of the warping mesh.
 6. Thecomputer-implemented method of claim 1, wherein modifying the firstimage area of the image based on the optimized mesh comprises:calculating a sampling of the optimized mesh; and modifying at least thefirst image area of the image based on the sampling of the optimizedmesh.
 7. The computer-implemented method of claim 1, wherein determiningthe first costs associated with the first portion of the warping meshcomprises: mapping the first image area to a first space using a firsttransformation, wherein the first transformation comprises a perspectivetransformation; mapping the first image area to a second space using asecond transformation, wherein the second transformation comprises astereographic transformation; determining a first aspect ratio for thefirst image area, the first aspect ratio based on a ratio of an area ofthe first space to an area of the second space; and determining thefirst costs associated with the first portion of the warping mesh basedon the first aspect ratio.
 8. The computer-implemented method of claim1, wherein the one or more face-related transformations of at least thefirst image area comprise a rotation of the first image area, atranslation of the first image area, and/or a scaling of the first imagearea, and wherein the determining the warping mesh for the imagecomprises: determining a third mesh for the image, the third meshcomprising a third plurality of vertices; and determining the warpingmesh based on the third mesh by at least: determining one or more sidesof the third mesh, and for each side of the one or more sides of thethird mesh: adding a pre-determined number of additional vertices to theside of the third mesh, after adding the pre-determined number ofadditional vertices to the side of the third mesh, determining aboundary of the third mesh that is associated with the side of the thirdmesh, the boundary associated with boundary vertices of the third mesh,and determining a dimension of the boundary vertices of the third meshto be perpendicular to a boundary of the image.
 9. Thecomputer-implemented method of claim 1, wherein the optimization of thecost function comprises a minimization of the cost function, and whereindetermining the optimized mesh based on the optimization of the costfunction comprises: determining the optimized mesh by performing theminimization of the cost function applied to the warping mesh,determining a left-maximum cost as a maximum of costs of vertices of aleft border of the optimized mesh; determining a right-minimum cost of aminimum of costs of vertices of a right border of the optimized mesh;determining a top-maximum cost as a maximum of costs of vertices of atop border of the optimized mesh; determining a bottom-minimum cost of aminimum of costs of vertices of a bottom border of the optimized mesh;and modifying the optimized mesh based on the left-maximum cost, theright-minimum cost, the top-maximum cost, and the bottom-minimum costby: determining a width scale for the image based on a width of theimage and a difference between the right-minimum cost and theleft-maximum cost; determining a height scale for the image based on aheight of the image and a difference between the bottom-minimum cost andthe top-maximum cost; and performing a mathematical scaling of theoptimized mesh based on the width scale and the height scale.
 10. Thecomputer-implemented method of claim 1, wherein the image comprises aplurality of pixels, and wherein modifying the first image area of theimage based on the optimized mesh comprises: determining a sampled meshby sampling the optimized mesh, the sampled mesh comprising a pluralityof sampled vertices; for a particular pixel of the plurality of pixels,modifying the particular pixel by at least: determining one or moreneighboring vertices of the plurality of sampled vertices that neighborthe particular pixel; determining coordinates for a resampled pixel ofthe plurality of pixels based on the one or more neighboring vertices;determining pixel values for the resampled pixel by sampling one or morepixels of the plurality of pixels based on the coordinates for theresampled pixel; and modifying the particular pixel based on the pixelvalues for the resampled pixel.
 11. The computer-implemented method ofclaim 1, wherein the image is part of a set of successive images, andwherein the warping mesh is initialized to an optimized mesh of aprevious image in the set of successive images.
 12. Thecomputer-implemented method of claim 1, wherein determining the firstimage area in the image comprises: applying a neural network on theimage to determine a segmentation mask, wherein the neural network istrained to determine a segmentation mask for a given input image; andproviding the segmentation mask as the first image area.
 13. Thecomputer-implemented method of claim 12, wherein the image is part of aset of successive images, and wherein applying the neural network on theimage comprises adding, to the image, a prior segmentation mask from aprevious image in the set of successive images.
 14. Thecomputer-implemented method of claim 13, wherein adding the priorsegmentation mask comprises resizing an output of the neural network forthe previous image to match one or more dimensions of the image.
 15. Thecomputer-implemented method of claim 12, wherein the neural networkcomprises a convolutional encoder-decoder neural network.
 16. Thecomputer-implemented method of claim 1, wherein the image is part of aset of successive images, wherein the warping mesh comprises a pluralityof vertices, and wherein determining the first costs associated with thefirst portion of the warping mesh comprises determining a coherence costby: comparing vertices of the warping mesh to the vertices of a priorwarping mesh from a previous image in the set of successive images, anddetermining the coherence cost based on the comparison.
 17. Thecomputer-implemented method of claim 16, wherein determining thecoherence cost further comprises mathematically scaling the comparisonby applying a weighting parameter, wherein the weighting parameter isassociated with a number of regions of interests in the image.
 18. Thecomputer-implemented method of claim 17, wherein the weighting parameteris increased if the number of regions of interests has changed from theprevious image, and the weighting parameter is decreased if the numberof regions of interests has not changed from the previous image.
 19. Thecomputer-implemented method of claim 1, wherein the image is part of aset of successive images, wherein the warping mesh comprises a pluralityof vertices, and wherein determining the first costs associated with thefirst portion of the warping mesh comprises determining a predictioncost by: comparing vertices of the warping mesh to the vertices of aprior warping mesh from a previous image in the set of successiveimages, comparing vertices of the warping mesh to the vertices of asecond prior warping mesh from a second previous image in the set ofsuccessive images, and determining the prediction cost based on thecomparisons.
 20. A computing device, comprising: one or more processors;and one or more computer readable media having computer-readableinstructions stored thereon that, when executed by the one or moreprocessors, cause the computing device to carry out functions thatcomprising: determining a first image area in an image; determining awarping mesh for the image; determining a first portion of the warpingmesh, wherein the first portion of the warping mesh is associated withthe first image area; determining a cost function for the warping meshby determining first costs associated with the first portion of thewarping mesh, wherein the first costs comprise costs associated with oneor more face-related transformations to correct one or more geometricdistortions in the first image area; determining an optimized mesh basedon an optimization of the cost function for the warping mesh; andmodifying the first image area in the image based on the optimized mesh.21. The computing device of claim 20, wherein determining the firstimage area in the image comprises: applying a neural network on theimage to determine a segmentation mask, wherein the neural network istrained to determine a segmentation mask for a given input image; andproviding the segmentation mask as the first image area.
 22. Thecomputing device of claim 20, wherein the image is part of a set ofsuccessive images, wherein the warping mesh comprises a plurality ofvertices, and wherein determining the first costs associated with thefirst portion of the warping mesh comprises determining a coherence costby: comparing vertices of the warping mesh to the vertices of a priorwarping mesh from a previous image in the set of successive images, anddetermining the coherence cost based on the comparison.
 23. An articleof manufacture comprising one or more computer readable media havingcomputer-readable instructions stored thereon that, when executed by oneor more processors of a computing device, cause the computing device tocarry out functions comprising: determining a first image area in animage; determining a warping mesh for the image; determining a firstportion of the warping mesh, wherein the first portion of the warpingmesh is associated with the first image area; determining a costfunction for the warping mesh by determining first costs associated withthe first portion of the warping mesh, wherein the first costs comprisecosts associated with one or more face-related transformations tocorrect one or more geometric distortions in the first image area;determining an optimized mesh based on an optimization of the costfunction for the warping mesh; and modifying the first image area in theimage based on the optimized mesh.
 24. The article of manufacture ofclaim 23, wherein determining the first image area in the imagecomprises: applying a neural network on the image to determine asegmentation mask, wherein the neural network is trained to determine asegmentation mask for a given input image; and providing thesegmentation mask as the first image area.
 25. The article ofmanufacture of claim 23, wherein the image is part of a set ofsuccessive images, wherein the warping mesh comprises a plurality ofvertices, and wherein determining the first costs associated with thefirst portion of the warping mesh comprises determining a coherence costby: comparing vertices of the warping mesh to the vertices of a priorwarping mesh from a previous image in the set of successive images, anddetermining the coherence cost based on the comparison.